mardi 5 mai 2015

Rails 4.2 Concern not included

I am trying to extend a module using Concern. The following file is saved as app/models/concerns/plutus_account_extenison.rb

module PlutusAccountExtension
  extend ActiveSupport::Concern

  included do
    belongs_to :party, class_name: 'V1::Party'
  end
end
Plutus::Account.send :include, PlutusAccountExtension

On load, the above concern is not included in Plutus::Account model. I can include the concern in rails console.

[1] pry(main)> Plutus::Account.reflect_on_all_associations(:belongs_to)
=> []


[2] pry(main)> Plutus::Account.send :include, PlutusAccountExtension
=> Plutus::Account (call 'Plutus::Account.connection' to establish a   connection)
[3] pry(main)> Plutus::Account.reflect_on_all_associations(:belongs_to)
=> [#<ActiveRecord::Reflection::BelongsToReflection:0x007fe9f5060130
  @active_record=Plutus::Account (call 'Plutus::Account.connection' to establish a connection),
  @association_scope_cache={},
  @automatic_inverse_of=nil,
  @constructable=true,
  @foreign_type="party_type",
  @klass=nil,
  @name=:party,
  @options={:class_name=>"V1::Party"},
  @plural_name="parties",
  @scope=nil,
  @scope_lock=#<Mutex:0x007fe9f507be08>,
  @type=nil>]

V

Aucun commentaire:

Enregistrer un commentaire