app/models/page.rb in tkh_content-0.9.20 vs app/models/page.rb in tkh_content-0.10
- old
+ new
@@ -1,18 +1,22 @@
-# 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 Page < ActiveRecord::Base
belongs_to :author, class_name: 'User'
has_many :comments, as: :commentable, :dependent => :destroy
has_many :taggings, :dependent => :destroy
has_many :tags, through: :taggings
+ tkh_searchable
+ def self.tkh_search_indexable_fields
+ indexable_fields = {
+ title: 8,
+ description: 3,
+ body: 2
+ }
+ end
+
validates_presence_of :title
validates_presence_of :description
validates_presence_of :body
validates_presence_of :author_id
@@ -33,9 +37,13 @@
scope :by_title, -> { order('title') }
scope :by_menu_position, -> { order('menu_position') }
def nickname
@nickname ||= short_title || title
+ end
+
+ def published?
+ published_at.present? ? true : false
end
### menu related instance methods
def orphan?