public
Description: Rails Plugin - a RailsEngines-based CMS extension for any Rails project
Homepage: http://6brand.com
Clone URL: git://github.com/JackDanger/simple_pages.git
studioda (author)
Tue Feb 20 14:52:32 -0800 2007
commit  28886df21b99b11fb452a8ad929ea7fc77da2f6e
tree    ddad99ad52c9635218697bceacd8017730c11c1a
parent  1aa1cfb1b026aebd5fe58b59809a0643ddc1a23c
simple_pages / app / models / simple_page.rb
100644 24 lines (18 sloc) 0.728 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class SimplePage < ActiveRecord::Base
 
  # make sure to install the acts_as_versioned plugin to make simple_pages revisioning work!
  # $ ruby script/plugin source http://svn.techno-weenie.net/projects/plugins
  # $ ruby script/plugin install -x acts_as_versioned
  acts_as_versioned if respond_to?(:acts_as_versioned)
 
  validates_presence_of :filename, :title
  validates_uniqueness_of :filename, :title
  
  before_save :fix_filename
  before_save :process_content
  
  # Page#to_param is used to fill the :id portion of the request. This gives us pretty urls.
  def to_param
    self.filename
  end
 
  # make lowercase and underscored
  def fix_filename
    self.filename = filename.downcase.gsub(' ', '_')
  end
  
end