The serialized object works fine in my dev block, Heroku gives "TypeError (cannot throw an anonymous class class)"

Maybe I'm misusing serialized objects, so I apologize in advance. For the activity feed, I use a serialized metadata column to simplify the database call. For instance. for an activity feed, I just deal with Activity objects with the corresponding user_id. I am adding a line_item to the object as shown here:

class Activity < ActiveRecord::Base serialize :data activity = Activity.new(:user_id => user_id...) if activity.source_type == "LineItem" line_item = LineItem.find(activity.source_id) activity.update_attributes(:data => line_item) end 

Then I call it through some particles, where the “book” is a bit of metadata:

 = link_to image_tag(item.data.book.image_url), book_path(item.data.book.id) 

This works fine on my box, but Heroku gives me "TypeError (cannot throw an anonymous class class)". What gives?

+4
source share
1 answer

I think you need to explicitly tell what type you are serializing to. Thus, the syntax will look like this:

 serialize :data, Hash 
+1
source

Source: https://habr.com/ru/post/1394531/


All Articles