Skip to content

Commit

Permalink
fixed some bugs in migration generation, so that full_path and slug g…
Browse files Browse the repository at this point in the history
…ets generated
  • Loading branch information
aslakjo committed Oct 20, 2009
1 parent 831128d commit 01973e1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nbproject
4 changes: 2 additions & 2 deletions comatose.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated on Tue May 20 20:13:12 -0500 2008
Gem::Specification.new do |s|
s.name = "comatose"
s.version = "2.0.5.8"
s.name = "aslakjo-comatose"
s.version = "2.0.5.9"
s.date = "2008-10-31" # 2008-05-20
s.summary = "Micro CMS designed for being embedded into existing Rails applications"
s.email = "[email protected]"
Expand Down
7 changes: 1 addition & 6 deletions generators/comatose_migration/templates/migration.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
class ComatosePage < ActiveRecord::Base
set_table_name 'comatose_pages'
acts_as_versioned :table_name=>'comatose_page_versions', :if_changed => [:title, :slug, :keywords, :body]
end


class <%= class_name %> < ActiveRecord::Migration
Expand All @@ -24,7 +19,7 @@ def self.up
end
ComatosePage.create_versioned_table
puts "Creating the default 'Home Page'..."
ComatosePage.create( :title=>'Home Page', :body=>"h1. Welcome\n\nYour content goes here...", :author=>'System' )
Comatose.create_root_page( :title=>'Home Page', :body=>"h1. Welcome\n\nYour content goes here...", :author=>'System' )
end

def self.down
Expand Down
12 changes: 4 additions & 8 deletions lib/comatose.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,9 @@ def self.load_extensions

module Comatose
def self.create_root_page(options ={})
unless ComatosePage.root
page = ComatosePage.create({:title=>'root page', :body=>"Welcome to comatose", :author=>'System', :parent_id=>nil}.merge(options))
page.save(false)
else
raise "There exists a comatose root page, cant create another one"
end
rescue
true
raise "Root page already exists" if ComatosePage.root
root = ComatosePage.create({:title=>'root page', :body=>"Welcome to comatose", :author=>'System', :parent_id=>nil}.merge(options))
root.save(false)
raise "Failed to save root page" if root.new_record?
end
end
3 changes: 2 additions & 1 deletion lib/comatose_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ComatosePage < ActiveRecord::Base
define_option :active_mount_info, {:root=>'', :index=>''}

acts_as_tree :order => "position, title"

acts_as_list :scope => :parent_id

#before_create :create_full_path
Expand Down Expand Up @@ -101,6 +102,7 @@ def self.find_by_path( path )
def record_timestamps
false
end

def self.record_timestamps
false
end
Expand All @@ -111,7 +113,6 @@ def after_save_hook
instance_eval &Comatose.config.after_page_save
end


# Creates a URI path based on the Page tree
def create_full_path
if parent_node = self.parent
Expand Down

0 comments on commit 01973e1

Please sign in to comment.