Grant Leslie Grant Leslie - 1 month ago 5x
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:

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!


try this:

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