Diego Couto
2013-Jul-19 12:52 UTC
Multiple select issue with a HABTM relationship using Rails 4
Although the code seems to be right, when I try to send the form, the values of the multiple select aren''t being sent.If I just remove the multiple option, everything works as expected considering just one value, but it''s important to store more than one tag per transaction. Do you have any ideas about what could be happening here? *Model* *Transaction.rb* class Transaction < ActiveRecord::Base has_and_belongs_to_many :tags *Tag.rb* class tag < ActiveRecord::Base has_and_belongs_to_many :transactions *View* <%= form.collection_select :tag_ids, @tags, :id, :name, {}, {:multiple => true} %> *Result:* <select id="transaction_tag_ids" multiple="multiple" name="transaction[tag_ids][]"> <option value="1">..</option> </select> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e0fc7483-efb9-440b-be5f-510971ed6fb3%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Hassan Schroeder
2013-Jul-20 14:26 UTC
Re: Multiple select issue with a HABTM relationship using Rails 4
On Fri, Jul 19, 2013 at 5:52 AM, Diego Couto <diego.gcouto-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Although the code seems to be right, when I try to send the form, the values > of the multiple select aren''t being sent.Are you sure about that? Check the log output from submitting the form. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yB2a3d6qP%2BUR1hv5gjCWANuRBeCSbFVtebXbj8WjH63%3Dg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.