Skip to content
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

Error while starting server with Rails 5.2.0.rc1 #224

Closed
unrooty opened this issue Jan 31, 2018 · 7 comments
Closed

Error while starting server with Rails 5.2.0.rc1 #224

unrooty opened this issue Jan 31, 2018 · 7 comments

Comments

@unrooty
Copy link

unrooty commented Jan 31, 2018

I updated to Rails 5.2.0.rc1 and now have such error:
activerecord-5.2.0.rc1/lib/active_record/coders/yaml_column.rb:24:in 'load': undefined method 'new' for Representable::JSON:Module (NoMethodError)

Can anybody help me with this issue?

@apotonick
Copy link
Member

Looks like Rails is grabbing the wrong constant - not in Representable's hand. Maybe dig into the yaml_column code?

@unrooty
Copy link
Author

unrooty commented Jan 31, 2018

This is the code of yaml_column.rb 'load' method:

def load(yaml)
return object_class.new if object_class != Object && yaml.nil?
return yaml unless yaml.is_a?(String) && /^---/.match?(yaml)
obj = YAML.load(yaml)
assert_valid_value(obj, action: "load")
obj ||= object_class.new if object_class != Object
obj
end

I think it tries to create an instance of module and throws exception while this process. But I don't understand why it tries to create instance of JSON module in yaml_column.

@apotonick
Copy link
Member

Yepp, must be somewhere further up the stack. Is Rails maybe looking for constants that equal JSON or something nasty like that? 🤔

@renchap
Copy link

renchap commented Jan 31, 2018

Could it be here: https://github.com/rails/rails/blob/master/activestorage/app/models/active_storage/blob.rb#L22 ? This is the first use of JSON when going up the stack.

@renchap
Copy link

renchap commented Feb 1, 2018

This is the culprit, replacing JSON with ActiveRecord::Coders::JSON fixes the issue. I will submit a PR to Rails.

@unrooty
Copy link
Author

unrooty commented Feb 1, 2018

@renchap thank for work. Waitng for megre.

@unrooty unrooty closed this as completed Feb 1, 2018
@unrooty unrooty reopened this Feb 1, 2018
georgeclaghorn pushed a commit to rails/rails that referenced this issue Feb 1, 2018
`JSON` constant defined.

For example when using the `representable` gem: trailblazer/representable#224
@renchap
Copy link

renchap commented Feb 1, 2018

It has been merged into the 5-2-stable branch. You can switch rails to this branch in your Gemfile to get the fix, or wait for the next Rails 5.2 version to be released.

@unrooty unrooty closed this as completed Feb 1, 2018
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

3 participants