anyone?

On Wednesday, February 13, 2013 12:09:17 PM UTC, devo...@gmail.com wrote:
>
> With the latest JSON gem 1.7.7, its breaking some of my code because I was 
> using:
>
>  {"json_class":"SomeClass","foo":"bar"}
>
> So the it doesn't recreate the "SomeClass" object back with the new gem 
> update, I can make it work by passing in  :create_additions => true but 
> that defeats the point of the update. The class has some attribute values 
> that are defined by the user's user_agent and cookie but in the code I 
> can't see a way to create new attribute by the user. 
>
> Simplified version of some of the code:
>
> class SomeClass
>   attr_accessor :name, :cookie, :user_agent
>
>   def initialize(params)
>     params = params.symbolize_keys
>     ['name', 'coookie', 'user_agent'].each do |attr_name|
>       self.send("#{attr_name}=", params[attr_name])
>     end
>   end
>
>   def to_json(*a)
>     {
>       'json_class'  => self.class.name,
>       'data'        => self.attributes
>     }.to_json(*a)
>   end
>
>   def self.json_create(o)
>     new(o['data'])
>   end
> end
>
> What's the best way to make it work properly? Is it safe to leave it as it 
> is and pass in  :create_additions => true?
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/oiK42dMZRK4J.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to