1

I'm trying to run rails with jruby
rails : 6.1.4.4 | jruby : 9.3.3.0 | ruby : 2.6.8

I get this error for when i try to use any Model(s) In rails console

User.all.limit(1)
Traceback (most recent call last):
        4: from (irb):2:in `evaluate'
        3: from app/models/user.rb:1:in `<main>'
        2: from app/models/application_record.rb:1:in `<main>'
        1: from app/models/application_record.rb:2:in `<class:ApplicationRecord>'
NameError (undefined local variable or method `primary_abstract_class' for #<Class:0x558123>)
Did you mean?  primary_class?

I have a User Model app/models/user.rb

class User < ApplicationRecord
end

app/models/application.rb

class ApplicationRecord < ActiveRecord::Base
  primary_abstract_class
end
Suhas C V
  • 104
  • 1
  • 5
  • 2
    Looks like `primary_abstract_class` was added in rails 7.0. https://github.com/rails/rails/releases Did you add that yourself, if so, or really either way, remove it and everything should work appropriately. – engineersmnky Feb 04 '22 at 02:31
  • I had to switch rails from `7.0` to `6.1.4.4` to run it on jruby, because the latest jruby `9.3.3.0` requires ruby `<2.7` and rails `7.0` requires atleast ruby `2.7`. – Suhas C V Feb 04 '22 at 16:29

1 Answers1

2

As already mentioned primary_abstract_class is introduced in Rails 7.

In Rails < 7 the ApplicationRecord is generated with:

# app/models/application_record.rb
class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
end
Mr. Ronald
  • 687
  • 4
  • 13