You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This solution cannot be used when you extend ApplicationRecord or ActiveRecord::Base directly ( ActiveRecord::Base.extend ActiveHash::Associations::ActiveRecordExtensions (docs).
Steps to Reproduce the Problem
execute rails new my_active_hash_test --minimal
Add active_hash to Gemfile, and bundle install
bundle exec rake db:create
bundle exec rails g model Foo, bundle exec rails g model Bar
Bar
/Users/qsona/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/associations/builder/association.rb:53:in `build_scope': undefined method `arity' for {:primary_key=>:code, :foreign_key=>:foo_code}:Hash (NoMethodError)
The text was updated successfully, but these errors were encountered:
@kbrock the needs seems not to be the same, basically I just added class_name: '...' to the belongs_to call and it is sufficient to raise the exception described.
Environment
Problem
This works
But this doesn't work.
error message:
Note that this error occurs when the Bar class is first loaded, not when executing
bar.foo
.Temporal solution
It can be avoided by first calling
belongs_to
and thenextend ActiveHash::Associations::ActiveRecordExtensions
.e.g.
This solution cannot be used when you extend ApplicationRecord or ActiveRecord::Base directly (
ActiveRecord::Base.extend ActiveHash::Associations::ActiveRecordExtensions
(docs).Steps to Reproduce the Problem
rails new my_active_hash_test --minimal
active_hash
to Gemfile, and bundle installbundle exec rake db:create
bundle exec rails g model Foo
,bundle exec rails g model Bar
bundle exec rails c
and add records, thenBar#foo
can be called successfullybundle exec rails c
, and loadBar
classThe text was updated successfully, but these errors were encountered: