Hello, I got the following application: http://pastie.org/901794 (I pasted only the most relevant parts.) It gives an error, while I try to submit the form, specifically: ActiveRecord::AssociationTypeMismatch in BeiratkozasController#create Modul(#51370284) expected, got String(#35011620) It also does this if I change html << radio_button(model_name, method, option) to html << radio_button(model_name, method, option.id). It generates the form, and the form works if I comment out the helper, so it adds the other fields to the database (those fields are not included in the pastie for length issues), but it fails while I wish to add the "modul". Thanks a thousand times and happy Easter! Peter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
By the way, does anyone know a more complex tutorial on has_many :through, since in books I have, and on the net, there are only basic uses, but I can''t find anything that deals with more complicated situations, like the one in my previous post. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I solved this in a kind of an odd way: def create @student = Student.new(params[:student]) respond_to do |format| if @student.save student_id = @student.id @subscription = Subscription.new(:modul_id => params[:valasztott_training]["moduls"], :student_id => student_id) @subscription.save format.html { redirect_to("/hallgato/"+student_id.to_s) } else format.html { render :action => "new" } end end en -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 3, 5:24 pm, WSzP <c...-6nYcUAqTnno@public.gmane.org> wrote:> Hello, > I got the following application:http://pastie.org/901794(I pasted > only the most relevant parts.) > It gives an error, while I try to submit the form, specifically: > ActiveRecord::AssociationTypeMismatch in BeiratkozasController#create > Modul(#51370284) expected, got String(#35011620) > > It also does this if I change html << radio_button(model_name, method, > option) to html << radio_button(model_name, method, option.id).The parameters submitted via a form are always strings (or arrays / hashes containing strings) - You''ve ended up supplying a string where active record expected actual instances of objects. In this particular case you might try making your form helpers assign to collection_ids rather than collection Fred -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.