in my migration is have: t.string :options in my model i have: serialize :options in my controller create and update I am doing the following: @vehicle.options = {:ac_front => params[:ac_front], :ac_rear => params[:ac_rear], :air_bag_driver => params[:air_bag_driver], :air_bag_passenger => params[:air_bag_passenger], :air_bag_side => params[:air_bag_side], :alloy_wheels => params[:alloy_wheels] } where all the params being passed are boolean true or false values. But for some reasons the values of the params do not get saved in the db. What am i doing wrong? -- 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.
I think the column you use for serializing should be a text column. Try this in your migration: t.text :options -- 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.
Tim Shaffer wrote in post #1000366:> I think the column you use for serializing should be a text column. > > Try this in your migration: > > t.text :optionsI was following the info provided on this page. http://railsforum.com/viewtopic.php?id=22651 and it states that it must be String. Though I tried it with String and Text both and the result was the same. Something else must be an issue. -- 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.
I''ve always used Text, otherwise, you''re mighty limited in what you can store there. Never had any problem with it, either. Walter On May 23, 2011, at 9:06 AM, QAS WM wrote:> Tim Shaffer wrote in post #1000366: >> I think the column you use for serializing should be a text column. >> >> Try this in your migration: >> >> t.text :options > > I was following the info provided on this page. > > http://railsforum.com/viewtopic.php?id=22651 > > and it states that it must be String. Though I tried it with String > and > Text both and the result was the same. Something else must be an > issue. > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On May 23, 12:23 pm, QAS WM <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> in my migration is have: > > t.string :options > > in my model i have: > > serialize :options > > in my controller create and update I am doing the following: > > @vehicle.options = {:ac_front => params[:ac_front], > :ac_rear => params[:ac_rear], > :air_bag_driver => params[:air_bag_driver], > :air_bag_passenger => params[:air_bag_passenger], > :air_bag_side => params[:air_bag_side], > :alloy_wheels => params[:alloy_wheels] } > > where all the params being passed are boolean true or false values. >So what does get saved in the database. What does the params hash look like at the point where this code runs? Fred> But for some reasons the values of the params do not get saved in the > db. What am i doing wrong? > > -- > 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.
Frederick Cheung wrote in post #1000379:> > So what does get saved in the database. What does the params hash look > like at the point where this code runs? > > FredValues for each of the items in the hash are nil. If I replace the params[:ac_rear] for example :ac_rear => params[:ac_rear] with true or false :ac_rear => true, that does get saved and shows as such. -- 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 23 May 2011 17:18, QAS WM <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Frederick Cheung wrote in post #1000379: >> >> So what does get saved in the database. What does the params hash look >> like at the point where this code runs? >> >> Fred > > Values for each of the items in the hash are nil. If I replace the > params[:ac_rear] for example > > :ac_rear => params[:ac_rear] > > with true or false > > :ac_rear => true, > > that does get saved and shows as such.Then it is nothing to do with the serialization, it is params that is not setup at the point you assign it to @vehicle.options. Look in development.log to see what params are being posted. If you can''t get to the bottom of it then probably best to start a new thread as the subject line is now inappropriate. 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.