Sha256: 509ce720ecd906d6a88447e1e99d82bcbdf426b0fdd0a588a2f811daf6cabcc6

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

module Recommendable
  class Stash < ActiveRecord::Base
    self.table_name = 'recommendable_stashes'
    attr_accessible :user_id, :stashable_id, :stashable_type

    belongs_to :user, :class_name => Recommendable.user_class.to_s, :foreign_key => :user_id
    belongs_to :stashable, :polymorphic => :true
    
    validates :user_id, :uniqueness => { :scope => [:stashable_id, :stashable_type],
                                         :message => "has already stashed this item" }
    def stashable_type=(sType)
      super sType.to_s.classify.constantize.base_class.to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recommendable-0.2.1.1 app/models/recommendable/stash.rb