Sha256: e19b653b31e55e779397bd3111d6a5da2d7ea33cfedb8c38a5233315fd21559d

Contents?: true

Size: 894 Bytes

Versions: 10

Compression:

Stored size: 894 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 :page
  
  # non-accessible attributes: author_id, :status, :locale
  attr_accessible :body, :page_id
  
  validates_presence_of :page_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

10 entries across 10 versions & 1 rubygems

Version Path
tkh_content-0.4.7 app/models/comment.rb
tkh_content-0.9.1 app/models/comment.rb
tkh_content-0.9 app/models/comment.rb
tkh_content-0.4.6 app/models/comment.rb
tkh_content-0.4.5 app/models/comment.rb
tkh_content-0.4.4 app/models/comment.rb
tkh_content-0.4.3 app/models/comment.rb
tkh_content-0.4.2 app/models/comment.rb
tkh_content-0.3.1 app/models/comment.rb
tkh_content-0.3 app/models/comment.rb