Ruby on Rails Friday, June 1, 2012

Hi,


You can check condition like this

 if params[:booking].kind_of? HashWithIndifferentAccess
  // logic here
end

On Fri, Jun 1, 2012 at 6:26 PM, Espen Antonsen <espen@inspired.no> wrote:
My Booking model has: serialize :custom_data, Hash

From the console it works as expected saving values to the custom_data attribute.

But when having a form with parameters like this: booking[custom_data][hello] and creating a new object in the controller like this: Booking.new( params[:booking] ), values are saved in the database with added metadata like this: --- !ruby/hash:ActiveSupport::HashWithIndifferentAccess

How can get rid of the HashWithIndifferentAccess-metadata when saving from a form?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/1WO6HkqIqjAJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.



--
Thanks & Regards,
MuraliDharaRao.T
+91-9642234646

--
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@googlegroups.com.
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.

No comments:

Post a Comment