Skip to content

Exception when create a record with a serialized attribute (active record 3.0.20) #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sobrinho opened this issue Oct 15, 2013 · 1 comment

Comments

@sobrinho
Copy link

Hey @tlconnor,

I'm working in a legacy project which we're trying to upgrade but right now that's not possible (lot of code, can't stop the production servers, almost no coverage, etc) so we have to keep with rails 3.0.20 for now.

The problem is happening with all models which have serialized attributes, all of this models there is no array columns btw.

You can reproduce the problem creating a empty model with a serialized attribute like this:

class Post < ActiveRecord::Base
  serialize :meta
end

When we try to create a record, the following exception is raised:

NoMethodError (undefined method `serialized_value' for #<ActiveSupport::HashWithIndifferentAccess:0x007f86ecc36610>)

Looking at source code, I found the problem at this line.

The problem is that method is different for each version of active record:

I fixed it monkey patching the method to the similar version for 3.0 on my application but it would be great if we fix that on activerecord-postgres-array since we will keep using it until we can get to 4.0 which is planned to 5 or 6 months from now.

In the past we did a kind of check for each version of active record on ar-octopus due to a similar problem, you can see the solution at these lines which is not elegant but solves the same problem.

What do you think? Would you accept a pull request fixing the compatibility for rails 3.0 and 3.1?

@sobrinho
Copy link
Author

Closing since we upgraded our application to 3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant