Setting additional parameters for the Ruby on Rails root on routes. Rb
You can do this in a view using Javascript if certain parameters exist.
For example in home.html.erb
<% if params[:your_param] == true %>
<script type="text/javascript">
// fire modal
</script>
<% end %>
And then just add your parameter to the query string:
http://www.yoursite.com/?your_param=true
No need to modify the routes file. Modals are related to the view, so why not keep the logic in the view?
As far as your comment is about conditional redirection sounds like a job for the controller. You also have access to the parameters in the controller, so you can redirect as needed based on the parameters passed to the action.
source to share
One way to do it that I used routes.rb
is this:
# config/routes.rb
get 'posts/:id(/:opt1(/:opt2(/:opt3)))' => 'posts#show'
Then we debug the parameters in the view
# app/views/posts/show.html.erb
<%= params %>
If url posts/1/A/B/C
This shows:
{"controller"=>"posts", "action"=>"show", "id"=>"1"
"opt1"=>"A", "opt2"=>"B", "opt3"=>"C"}
The parentheses in the route are optional and are treated as parameters for the non-parenthesis portion of the route.
source to share