I have setup a basic conference registration form. Within that form I
have an optional piece of information that would only be filled out if
the registrant was a vendor. Here is my relationship:
Registration has_one :vendor
Vendor belongs_to :registration
I want to be able to send both the vendor information and registration
information with the same form, but the vendor information might not be
sent if the registrant wasn''t a vendor. I have my fields set up for
the
vendor but I don''t think they are right:
<%= select("vendor", "donation", [[''Door
Prize'', ''doorprize''],
[''Monetary donation for door prize'',
''monetary''], [''Sponsor food
event?breakfast ($700)'', ''breakfast''],
[''Sponsor food event?snack
($300)'', ''snack''], [''Sponsor food
event?dinner ($3000)'', ''dinner''],
[''Sponsor entertainment at dinner ($650)'',
''entertainment''] ],
{:include_blank => true})%>
<%= select("vendor", "monetary_donation",
[[''$100'', ''100''], [''$200'',
''200''], [''$300'', ''300''],
[''$400'', ''400''], [''$500'',
''500''], [''$600'',
''600''] ], {:include_blank => true})%>
<%= text_field ''vendor'', ''other'' %>
<%= check_box "vendor", "electricity" %>
I get the error "Vendor expected, got String." Do I need to manually
insert the vendor data in the controller? Like this:
@reg = Registration.new(params[:registration])
@reg.vendor.donation = params[:vendor_donation]
@reg.vendor.monetary_donation = params[:vendor_monetary_donation]
@reg.vendor.other = params[:vendor_other]
@reg.vendor.electricity = params[:vendor_electricity]
Or is there an easier way?
--
Posted via http://www.ruby-forum.com/.