Im trying to get the multiple selected data from select_tag., but its
gives single data
I hv written.
<%=select_tag( :cons_attribute_id,options_from_collection_for_select
(Attribute.find_all_by_attributetype("cons"),
"id", "name", 3),:multiple=>true) %>
I hv also written as:
<%=select_tag( :cons_attribute_id[],options_from_collection_for_select
(Attribute.find_all_by_attributetype("cons"),
"id", "name", 3),:multiple=>true) %>
but it gives error.. such as method not defined
Frederick Cheung
2009-May-11 12:13 UTC
Re: how to get the multiple selected data from select_tag.
On May 11, 12:18 pm, nishi <n.mridut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > <%=select_tag( :cons_attribute_id[],options_from_collection_for_select > (Attribute.find_all_by_attributetype("cons"), > "id", "name", 3),:multiple=>true) %> > > but it gives error.. such as method not definedwhen you write :foo[] ruby thinks that you want to call the [] method on the symbol :foo. You can be explicit that you want the symbol with content foo[] by doing :''foo[]'' In this case you could also just pass a string to select_tag Fred
Arun Kumar
2009-May-11 12:22 UTC
Re: how to get the multiple selected data from select_tag.
Hi Nishi, Follow the blog<http://railsbuilder.blogspot.com/2009/05/multiple-select-option-in-rails.html>it may help you http://railsbuilder.blogspot.com/2009/05/multiple-select-option-in-rails.html Thanks On Mon, May 11, 2009 at 4:48 PM, nishi <n.mriduta07-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Im trying to get the multiple selected data from select_tag., but its > gives single data > > I hv written. > <%=select_tag( :cons_attribute_id,options_from_collection_for_select > (Attribute.find_all_by_attributetype("cons"), > "id", "name", 3),:multiple=>true) %> > > I hv also written as: > > <%=select_tag( :cons_attribute_id[],options_from_collection_for_select > (Attribute.find_all_by_attributetype("cons"), > "id", "name", 3),:multiple=>true) %> > > but it gives error.. such as method not defined > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thx Fred and Arun.
I got the solution,
<%=select_tag("attribute_id[]",options_from_collection_for_select
(Attribute.find_all_by_attributetype("cons"), "id",
"name",
3),:multiple=>true) %>
Hi Fred,
thx for ur resp.
but i hv one more ques.
here we r using the
options_from_collection_for_select
(Attribute.find_all_by_attributetype("cons")
I need a solution where we will get the data from model not directly
by "collection_select"
please give me sm idea, i need it as soon as possible.