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

Compatibility with Rails 7 #2610

Closed
wxw-matt opened this issue Mar 3, 2022 · 6 comments
Closed

Compatibility with Rails 7 #2610

wxw-matt opened this issue Mar 3, 2022 · 6 comments
Assignees
Labels
Milestone

Comments

@wxw-matt
Copy link

wxw-matt commented Mar 3, 2022

How to reproduce

Using Docker image:

docker run --rm -it ghcr.io/flavorjones/truffleruby:nightly-slim bash
# In the shell inside the container:
apt-get update
apt-get install xz-utils git libpq-dev libsqlite3-dev -y
gem install nokogiri --platform=ruby
gem install rails
rails new blog 
rails g scaffold comment2 title:string content:string

You will get the error:

      invoke  active_record
      create    db/migrate/20220302010737_create_comment2s.rb
      create    app/models/comment2.rb
      invoke    test_unit
      create      test/models/comment2_test.rb
      create      test/fixtures/comment2s.yml
      invoke  resource_route
       route    resources :comment2s
      invoke  scaffold_controller
/usr/local/bundle/gems/jbuilder-2.11.5/lib/generators/rails/templates/controller.rb:11:in `block (3 levels) in <unused>': undefined method `all' for ActiveModel:Module (NoMethodError)
@eregon
Copy link
Member

eregon commented Mar 3, 2022

Thanks for the report, Rails 5 & 6 work (tested here), but we didn't test Rails 7 yet.

gem install nokogiri --platform=ruby should be unnecessary (it'll be installed by bundler later on if needed), why is that done?

@bjfish Could you investigate?
I would try to repro outside Docker for convenience.

@eregon eregon changed the title Compatibility with Rails 7 (maybe other versions as well) Compatibility with Rails 7 Mar 3, 2022
@bjfish
Copy link
Contributor

bjfish commented Mar 3, 2022

I think this is a smaller reproduction case:

module ActiveRecord
end
module Generators
end
module ActiveModel
end

p Object.const_get("ActiveRecord::Generators::ActiveModel")

Actual

ActiveModel

Expected

in `const_get': uninitialized constant ActiveRecord::Generators (NameError)

See:

names.each do |s|
if Primitive.object_kind_of?(res, Module)
res = res.const_get(s, inherit)
else
raise TypeError, "#{name} does not refer to a class/module"
end
end

@bjfish bjfish self-assigned this Mar 3, 2022
@bjfish bjfish added this to the 22.1.0 milestone Mar 11, 2022
@bjfish
Copy link
Contributor

bjfish commented Mar 11, 2022

@wxw-matt This issue is now fixed at 1c888c9. Thanks.

@bjfish bjfish closed this as completed Mar 11, 2022
@bjfish bjfish added the bug label Mar 11, 2022
@wxw-matt
Copy link
Author

wxw-matt commented Mar 12, 2022

@bjfish Thank you all very much. Just wondering if the patch is available in the nightly built Docker image?
Will have a tutorial about Truffleruby and latest Rails 7.
Anyway, I will try it now.

@eregon
Copy link
Member

eregon commented Mar 12, 2022

@wxw-matt As long as the build at https://github.com/flavorjones/truffleruby/pkgs/container/truffleruby is after 1c888c9 it should be fine (not the case yet, needs ~4 hours more).

@wxw-matt
Copy link
Author

Thanks @eregon. Yeah, the current image does not have this patch. Waiting for the latest Docker image built with this fix.

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

No branches or pull requests

3 participants