Sha256: aee04c949a0fb957b78b389ffa409fe16f0e42d59e690488fd1f5348c7591687

Contents?: true

Size: 378 Bytes

Versions: 5

Compression:

Stored size: 378 Bytes

Contents

ActiveRecord::Base.class_eval do

  def self.scoped_to_account
    belongs_to :account, :class_name => "Mtdevise::Account"
    association_name = self.to_s.downcase.pluralize
    Mtdevise::Account.has_many association_name.to_sym, :class_name => self.to_s
    
    instance_eval <<-HERE
    def scoped_to(account)
    where(:account_id => account.id)
    end
    HERE
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mtdevise-4.1.2 lib/mtdevise/active_record_extensions.rb
mtdevise-4.1.1 lib/mtdevise/active_record_extensions.rb
mtdevise-4.1.0 lib/mtdevise/active_record_extensions.rb
mtdevise-4.0.0 lib/mtdevise/active_record_extensions.rb
mtdevise-3.10.2 lib/mtdevise/active_record_extensions.rb