Frederick Cheung wrote:
> On Nov 12, 5:18�am, Raji Mani <[EMAIL PROTECTED]>
> wrote:
>>
>> issue is how do i differentiate radio buttons with the same name.. both
>> the radio buttons are getting selected :(.. here is the code
>>
> the builders yielded by form_for and fields_for have the same name, so
> they'll be overwriting each other (which isn't what I thing you want).
> Also shouldn't the second parameter to radio_button be index and not
> 'index' ?
>
> Fred
ya. got it. But there exists an issues.. When i select radio button i ll
get the following error. . "undefined method `values' for "1":String"
where as the other values get saved if i do not select radio button.
Also If i enter only one email id the form is not getting saved.
Controller is as follows.
def new
@contact = Contact.new
2.times { @contact.emails.build }
end
def create
@contact = Contact.new(params[:contact])
params[:email].each_value do |email|
@contact.emails.build(email) unless email.values.all?(&:blank?)
end
if @contact.save
flash[:notice] = "Successfully created new Contact.!!!!!!!!!"
redirect_to :action => 'list'
else
render :action => 'new'
end
end
Where i went wrong?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---