Hi -
I'm trying to understand the help for this:
it says:
select(object, method, choices, options = {}, html_options = {})
questions-
1) what is 'object' ? Is this an ActiveRecord object? 2) what is method? 3) do i assume that my form object created from form_for calls select directly? 4) what is the form of object- is it "user", @user, user, or :user ? Please explain why, this is terribly confusing for a newbie.
So, if I have a view:
<% content_for(:page) do %> <h1>New user</h1> <% form_for :user, @user, :url => { :action => "create" } do |form| %> #NOTE I'M TRYING TO USE FORM_FOR <%= render :partial => 'form', :locals => { :form => form, :genders => @genders, :user=>@user} %> #SEND THE FORM INSTANCE DOWN TO PARTIAL <%= submit_tag "Create" %> <%end%> <%end%>
Notice I'm attempting to send the current user to the partial, I'm not sure if I'm doing this right. Also, my controller created a User instance (@user) which I'm sending to the partial.
and the partial:
<p> <label> Last Name<br/> <%= form.text_field :lastname %> </label> </p> ...
<p> <label> Gender<br/> <%= form.select('user', "gender", {"Male" => 1, "Female" =>2 })%> #THIS DOESN'T WORK </label> </p>
Note, there is no gender table, just 2 choices. User has a gender field which is an integer.
So all I'm trying to do is let the client choose a gender from a select box. Please tell me what I'm doing wrong and if possible, answer my questions above.
Thanks, Dino