Re: [Rails] Re: How to add button to pass drop down menu selection to controller
On Mon, Jul 23, 2012 at 12:12 PM, lalalalala pqpqpqpqpq
<lists@ruby-forum.com> wrote:
> <% form_tag(:controller => 'opt', :action => 'index', :id => 1) do %>
> <%= select_tag "option", options_for_select(@options, "") %>
> <%= submit_tag "go"%>
> <%end%>
> In my controller, for my index method I have:
>
> class optController < ApplicationController
which is wrong - s/b OptController
> def index
> @options = ["Option A", "Option B", "Option C"]
> end
> As you can see I'm only passing the id: 1 everytime I click go.
No, you're not. Again: look at your page using 'view source' in your
browser. Look *closely* at your form. Then go back and re-read the
doc for options_for_select.
Now select something, submit the form and see what's logged.
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home