Sha256: 067a640fa27c2f732f9448cb973e1b3723854c4b398269f9ddaf65870e2c4fbf

Contents?: true

Size: 379 Bytes

Versions: 4

Compression:

Stored size: 379 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

4 entries across 4 versions & 1 rubygems

Version Path
mtdevise-3.10.1 lib/mtdevise/active_record_extensions.rb
mtdevise-3.10.0 lib/mtdevise/active_record_extensions.rb
mtdevise-3.9.1 lib/mtdevise/active_record_extensions.rb
mtdevise-3.9.0 lib/mtdevise/active_record_extensions.rb