Jump to content

The ultimate community for Ruby on Rails developers.


Getting info from a dropdown menu

View Controller

  • Please log in to reply
No replies to this topic

#1 Tritonis



  • Members
  • 1 posts

Posted 01 August 2014 - 05:27 PM

I'm trying to learn rails by developing a small little graphing application, but I'm having some trouble sorting out dropdown menus. I have a homepage controller and an associated view index.html. My index action is this:


 def index
  @ccmh = Ccmh.all
  @column_names = Ccmh.columns.map {|a| a.name}
and my view is this: 
<select name="id">
<%= @ccmh.each do |abc|%>
<option value="<% abc.id %>"><%= abc.description %></option>
<% end %>
<select name="id">
<% @column_names.each do |a|%>
<option value ="<%@column_names.index%>"><%= a %></option>
<% end %>



This creates the dropdown menu with options/values populated from my database. What I want to do is get the user's selection from the drop down menus with a submit button. It would then pass the values along to another controller action, which would pass them along to the graphing utility I have setup. Currently I've no idea how to do this and the last few days of trying to google it hasn't gotten me anywhere. The big hitch at the moment is trying to get the submit button working. I think if I can get that, I can figure the rest out on my own. 


Any help would be greatly appreciated. 

Also tagged with one or more of these keywords: View, Controller

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users