Grant Leslie Grant Leslie - 3 months ago 9
Ruby Question

Rails string in the url to be readable by application?

I feel like this is simpler than I'm making it...basically, I'm wanting to give urls a parameter that is readable by my template view to display dynamic information. So, in example, if the url is:

www.myawesomesite.com/page/3?special_key=123


And my view would look something like:

<% if @special_key.present? && @special_key == 123 %>
Special Info!
<% end %>


Basically, how would I tell my rails app that 'special_key' is something it should look for as a parameter in the url? What do I add to the 'page' controller?

Thanks in advanced!

Answer

try this:

<% if params[:special_key] == '123' %>
  Special Info!
<% end %>
Comments