adarsh
adarsh

Reputation: 394

Serialized object works fine on my dev box, Heroku gives "TypeError (can't dump anonymous class Class)"

I may be using serialized objects wrong, so I apologize in advance. For an activity feed, I'm using a serialized meta-data column to simplify the database call. E.g. for the activity feed, I'm just pulling in Activity objects with the appropriate user_id. I'm adding in the line_item object as seen 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 via some partials where "book" is the meta-data bit:

= 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 (can't dump anonymous class Class)". What gives?

Upvotes: 4

Views: 446

Answers (1)

digitalWestie
digitalWestie

Reputation: 2797

I think you need to explicitly say what type you are serializing to. So the syntax would be:

serialize :data, Hash

Upvotes: 1

Related Questions