In Rails, I am trying to learn how to use params passed with link_to.
In one view I have
<%= link_to 'link', static_pages_params_path(info: 23) %>
Then in my StaticPagesController I have
def params
debugger
end
When I enter byebug after clicking the aforementioned link, I see
Started GET "/static_pages/params?info=23" for ::1 at 2016-08-17 11:05:43 -0500
Processing by StaticPagesController#params as HTML
Parameters: {"info"=>"23"}
Return value is: nil
From this it appears that I should be able to access params. However, when I enter params into byebug, I get nil:
(byebug) params
nil
I am debugging at this point because I was unable to access params[:info] from the params method.
What am I doing wrong here?
You're getting a name-space collision with the controller method overriding your params
variable. Consider changing your action name.