How to create dropdown menu for the following code in Rails 3?
Consider an HTML list of links:
<a href="/d_population/1">User 1 name link</a><br>
<a href="/d_population/2">User 2 name link</a><br>
This code generates the list:
<% User.all.each do |user| %>
<%= link_to user.name + " link", d_population_path(user.id) %><br>
<% end %>
The relevant route is:
match 'd_population/:this_client', :to => 'dashboard#population', :as => 'd_population'
I would like to use an HTML dropdown to make the same HTTP request.
Is it possible to use a dropdown to make a HTTP request that looks like /d_population/1
?
I attempted to use form_tag
and select_tag
to generate the drop开发者_运维百科down and pass this_client
as a parameter, but kept getting routing errors. Do you need to add a route d_population/
to make a dropdown work?
Thanks.
here are a few resources to help you get started with Dropdowns and Menu's
Tabs on Rails is an awesome Gem that will help you generate Li menu's in Rails http://www.simonecarletti.com/code/tabs_on_rails/
Bootstrap is a UI Framework, developed by Twitter http://twitter.github.com/bootstrap/
I've successfully implemented both of these in a current project that i've been working on.
精彩评论