i implemented a function to permit the parameters
def send_params
params.require(:article).permit(:color, :skin, :cover)
end
right now i want to know what parameter i am sending
for example only i am sending the color in this case:
#<ActionController::Parameters {"color"=>""} permitted: true>
with this conditional, is validating the value of color, does not matter the value, i am interesting the parameter that i am sending
if params_search[:color].present?
CodePudding user response:
You can use gem pry
- gem link: https://github.com/pry/pry
- code example will be:
def create
binding.pry
# some logic using `send_params`
end
- The steps:
- add
binding.pry
toaction
ofcontroller
- go to
Postman
and send data - go to console where running
rails s
- call
params
orsend_params
CodePudding user response:
In the logs you can see what params you are sending. For example if you post to /articles
and you send all three params you would see it like this:
Started POST "/articles" for [IP_ADDRESS] at [DATE_TIME_STAMP]
Processing by ArticlesController#create as [html/json/something_else]
Parameters: {"article"=>"{"color"=>"blue", "skin"=>"skin value", "cover"=>"some cover"}}
If you only send the color than the logs would look like this:
Started POST "/articles" for [IP_ADDRESS] at [DATE_TIME_STAMP]
Processing by ArticlesController#create as [html/json/something_else]
Parameters: {"article"=>"{"color"=>"blue"}}
You can access the params object with: params[:article]
and if you want to access the color: params[:article][:color]