i have a registration form ,i want to store data in corresponding user table in that hobbies field ,i want to store all hobbies in one column so i take multiple check boxes and store in one array all checked values for that i am using below tag,but not working,please any suggestion <%= check_box(:user ,:hobbies,:value =>''Games'') %>Games <%= check_box :user , :hobbies,:value =>''Music'' %>Music <%= check_box :user , :hobbies,:value => ''Shopping''%>Shopping the above user is table name ,hobbies is column name -- 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 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 Dec 28, 2:57 am, "Durga B." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> i have a registration form ,i want to store data in corresponding user > table in that hobbies field > ,i want to store all hobbies in one column so i take multiple check > boxes and store in one array > all checked values for that i am using below tag,but not working,please > any suggestion > <%= check_box(:user ,:hobbies,:value =>''Games'') %>Games > <%= check_box :user , :hobbies,:value =>''Music'' %>Music > <%= check_box :user , :hobbies,:value => ''Shopping''%>Shopping > the above user is table name ,hobbies is column name >You need to use check_box_tag, and the name of the parameter needs to end in []. THis will result in params[:foo] being an array which you an then do something sensible with. Fred> -- > Posted viahttp://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 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.
thank you ,thank you fred ,it will help in mytask -- 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 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.
Prasad B. wrote in post #970999:> i have a registration form ,i want to store data in corresponding user > table in that hobbies field > ,i want to store all hobbies in one columnNo you don''t. That''s VERY BAD database design. Please read about DB normalization. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- 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 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.
Frederick Cheung wrote in post #971033:> On Dec 28, 2:57am, "Durga B." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> > You need to use check_box_tag, and the name of the parameter needs to > end in []. THis will result in params[:foo] being an array which you > an then do something sensible with. > > FredThank you so much fred for your suggestion ,it will create for user registration page,please give me a solution for in user profile editing how it works .example i have 3 check boxes in editing ,which one is select in previous they are automatically checked please give any solution Thanks & Regards prasad -- 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 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.
please it is urgent for me any suggestion urgent -- 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 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 30 December 2010 13:39, Prasad B. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> please it is urgent for me any suggestion urgentSince you have not quoted any previous message it is not clear what you are wanting help with. Looking back at your original post it is not clear exactly what you are having difficulty with. I assume you have followed Marnen''s advice in his email. So having done that can you explain what the problem is? Colin -- 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 have a registration form ,i want to store data in corresponding user table in that hobbies field ,i want to store all hobbies in one column so i take multiple check boxes and store in one array all checked values for that i am using below tag,but not working,please any suggestion <%= check_box(:user ,:hobbies,:value =>''Games'') %>Games <%= check_box :user , :hobbies,:value =>''Music'' %>Music <%= check_box :user , :hobbies,:value => ''Shopping''%>Shopping the above user is table name ,hobbies is column name the above check boxes ,i want in registration,validating and mainly editing i want how to possible -- 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 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 30 December 2010 13:51, Prasad B. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: I am assuming that this is in response to my post, but again you have not quoted the previous message so I do not know. When replying please insert your reply into the previous message so that it is easier to follow the thread. Thanks> i have a registration form ,i want to store data in corresponding user > table in that hobbies field > ,i want to store all hobbies in one column so i take multiple check > boxes and store in one array > all checked values for that i am using below tag,but not working,please > any suggestion > <%= check_box(:user ,:hobbies,:value =>''Games'') %>Games > <%= check_box :user , :hobbies,:value =>''Music'' %>Music > <%= check_box :user , :hobbies,:value => ''Shopping''%>Shopping > the above user is table name ,hobbies is column nameIt has already been suggested that it is not a good idea to store the hobbies all in one column. What did you learn from reading about database normalisation? Hint: You could have a hobbies table and then have a has_and_belongs_to_many association between the models. Have a look at the Rails Guide on ActiveRecord Associations if this is not familiar to you. Colin -- 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.
Michael Pavling
2010-Dec-30 15:18 UTC
Re: Re: Re: cerating multiple check boxes using array
On 30 December 2010 13:51, Prasad B. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> i have a registration form ,i want to store data in corresponding user > table in that hobbies field > ,i want to store all hobbies in one column so i take multiple check > boxes and store in one arrayAt the risk of making the the thread start sounding like a broken record : "no you do not". It''s a dreadful idea to try to store all the hobbies in one (comma separated, I assume) field. Set up an association properly, and have done with it.> all checked values for that i am using below tag,but not working,please > any suggestion > > the above check boxes ,i want in registration,validating and mainly > editing i want how to possibleIf you insist on implementing your horribly broken solution to the problem, then you''ll need some helper methods in your model that take your single column and break it into an array, and take an array of ids (from the params array in the controller) and join it back into your field, such as: def hobby_ids self.hobbies.split(",") end def hobby_ids=(supplied_ids) self.hobbies = supplied_ids.join(",") end No-one is going to "help" more than this, as the correct solution is to "make an association", anything else is a hideous bodge that is going to lead to heartache and worry. -- 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.
Hi thank you very much ,you got my point and understand my thinking you suggest good idea ,i am new to ruby on rails so please suggest rails tags also for array of check boxes.How serialize array of that hobbies object and store in database -- 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 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.
Amar Jampa
2010-Dec-31 03:06 UTC
What is Mass Assignment Can you give me a clear idea about that with an example
What is Mass Assignment? Can you give me a clear idea about that with an example? -- 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 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 31 December 2010 02:52, Prasad B. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi thank you very much ,you got my point and understand my thinking you > suggest good idea ,i am new to ruby on rails so please suggest rails > tags also for array of check boxes.How serialize array of that hobbies > object and store in databaseIn order to understand better the basics of RoR I suggest you work through some tutorials and guides. Start with working through all the Rails Guides and also railstutorial.org (which is a free tutorial when used online). Then you will be able to answer most of your own questions. Come back and ask again if you still have problems. Colin -- 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 31 December 2010 02:52, Prasad B. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi thank you very much ,you got my point and understand my thinking you > suggest good ideaI''ve no idea who you''re thanking, as you didn''t quote any previous message.> ,i am new to ruby on rails so please suggest rails > tags also for array of check boxes.googling for "ruby rails tutorial" will give you lots of results. I recall that you''ve already been pointed at the documentation for associations, and it might be good for you to get a book to work through - "Agile Web Development With Rails" is highly recommended.> How serialize array of that hobbies > object and store in databaseYou can use the "serialize" method on a model.... but that''s *not* what you want to solve your problem - you want to use associations... it may have been mentioned already. Sorry for sounding terse... got a plane to catch :-) -- 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.
soldier
2010-Dec-31 10:13 UTC
Re: What is Mass Assignment Can you give me a clear idea about that with an example
you can use attr_accessible. On Fri, Dec 31, 2010 at 11:06 AM, Amar Jampa <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> What is Mass Assignment? > Can you give me a clear idea about that with an example? > > -- > 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 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. > >-- 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.