Sha256: 285c0e7aae04c8ee141d5837de6fbf07914f0b65cd37953ca2cc8dab3573e2bd
Contents?: true
Size: 1.39 KB
Versions: 5
Compression:
Stored size: 1.39 KB
Contents
class Page < ActiveRecord::Base include PublicActivity::Common include Tire::Model::Search include Tire::Model::Callbacks has_ancestry #touch: true acts_as_list scope: [:ancestry] attr_accessor :old_ancestor_ids belongs_to :creator_id has_many :attachments, as: :attachable, dependent: :destroy validates_presence_of :creator validates_presence_of :title belongs_to :creator, class_name: 'User' after_save :touch_ancestry def to_param [id, title.parameterize].join("-") end def wiki_dir "wiki/#{id}" end def update_to_gollum(user) commit = { message: 'no message', name: user.name, email: user.email } body_page = "#{id}-body" title_page = "#{id}-title" $wiki.write_page(wiki_dir + "/" + body_page, :textile, body, commit) $wiki.write_page(wiki_dir + "/" + title_page, :textile, title, commit) end def type @type || "Page" end def versions $wiki.page("#{id}-body", nil, wiki_dir).try(:versions) || [] end def reorder!(options) if options[:parent_id] self.old_ancestor_ids = self.ancestor_ids self.parent_id = options[:parent_id] self.save end self.insert_at options[:position].to_i self.save end def touch_ancestry self.old_ancestor_ids ||= [] Page.where(id: (ancestor_ids + old_ancestor_ids).uniq).update_all(updated_at: Time.now) end private end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
tawork-0.0.5 | app/models/page.rb |
tawork-0.0.4 | app/models/page.rb |
tawork-0.0.3 | app/models/page.rb |
tawork-0.0.2 | app/models/page.rb |
tawork-0.0.1 | app/models/page.rb |