0
私は5.1をレールにし、間違っているかを把握することはできませんアップグレードした後に、このエラーを取得しています:のRails 5.1:#<ActiveRecordは::アソシエーションの未定義のメソッド `apply_scope」:: AssociationScope
undefined method `apply_scope' for #<ActiveRecord::Associations::AssociationScope
関連するコードを次のとおりです。
def set_site
@site = current_account.sites.active.find(params[:id])
redirect_to sites_path if @site.nil?
@site
end
モデル:
class Site < ApplicationRecord
belongs_to :account
scope :active, (-> { where(workflow_state: 'active') })
# ....
end
フルスタックトレース:
composite_primary_keys (10.0.1) lib/composite_primary_keys/associations/association_scope.rb:35:in `block in last_chain_scope'
composite_primary_keys (10.0.1) lib/composite_primary_keys/associations/association_scope.rb:33:in `each'
composite_primary_keys (10.0.1) lib/composite_primary_keys/associations/association_scope.rb:33:in `last_chain_scope'
activerecord (5.1.0) lib/active_record/associations/association_scope.rb:126:in `add_constraints'
/usr/local/bundle/bundler/gems/activemodel-associations-8dab1043fc77/lib/active_model/associations/association_scope_extension.rb:10:in `add_constraints'
activerecord (5.1.0) lib/active_record/associations/association_scope.rb:28:in `scope'
activerecord (5.1.0) lib/active_record/associations/association_scope.rb:5:in `scope'
activerecord (5.1.0) lib/active_record/associations/association.rb:97:in `association_scope'
activerecord (5.1.0) lib/active_record/associations/collection_proxy.rb:1162:in `association_scope'
activerecord (5.1.0) lib/active_record/associations/collection_proxy.rb:1131:in `method_missing'
app/controllers/sites_controller.rb:215:in `set_site'