Sha256: 22c95d7fef745c9fd3885cfa3614b57dc6e465897597fa037dde834fab1349d5

Contents?: true

Size: 909 Bytes

Versions: 17

Compression:

Stored size: 909 Bytes

Contents

# this is needed for now to make mass assignment security compatible with the translation of globalize3
# Globalize::ActiveRecord::Translation.class_eval do
#   attr_accessible :locale
# end

class Comment < ActiveRecord::Base

  belongs_to :author, class_name: 'User', foreign_key: 'author_id'
  belongs_to :commentable, polymorphic: true

  validates_presence_of :commentable_type, :commentable_id, :author_id, :body

  scope :showable, -> { where('status = ? OR status = ?', 'pending', 'accepted') }
  scope :pending, -> { where('status = ?', 'pending') }
  scope :accepted, -> { where('status = ?', 'accepted') }
  scope :blocked, -> { where('status = ?', 'blocked') }
  scope :for_locale, lambda { |locale| where('locale = ?', locale) }
  scope :by_recent, -> { order('updated_at desc') }
  scope :by_created, -> { order('created_at') }
  scope :by_recently_created, -> { order('created_at desc') }

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
tkh_content-0.10.10 app/models/comment.rb
tkh_content-0.10.9 app/models/comment.rb
tkh_content-0.10.8 app/models/comment.rb
tkh_content-0.10.7 app/models/comment.rb
tkh_content-0.10.6 app/models/comment.rb
tkh_content-0.10.5.1 app/models/comment.rb
tkh_content-0.10.5 app/models/comment.rb
tkh_content-0.10.4 app/models/comment.rb
tkh_content-0.10.3 app/models/comment.rb
tkh_content-0.10.2 app/models/comment.rb
tkh_content-0.10.1 app/models/comment.rb
tkh_content-0.10 app/models/comment.rb
tkh_content-0.9.20 app/models/comment.rb
tkh_content-0.9.19 app/models/comment.rb
tkh_content-0.9.18 app/models/comment.rb
tkh_content-0.9.17 app/models/comment.rb
tkh_content-0.9.16 app/models/comment.rb