From 03e105b9e061ca658e0c8f3a3a05378390be4218 Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Wed, 27 Apr 2011 22:17:30 -0700 Subject: Ensure that the seeds don't blow up when either 'User' or 'Page' are not defined. --- db/seeds/refinerycms_blog.rb | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/db/seeds/refinerycms_blog.rb b/db/seeds/refinerycms_blog.rb index 9686c7f..0be2a06 100644 --- a/db/seeds/refinerycms_blog.rb +++ b/db/seeds/refinerycms_blog.rb @@ -1,18 +1,20 @@ -User.find(:all).each do |user| +::User.find(:all).each do |user| if user.plugins.where(:name => 'refinerycms_blog').blank? user.plugins.create(:name => "refinerycms_blog", :position => (user.plugins.maximum(:position) || -1) +1) end -end +end if defined?(::User) -page = Page.create( - :title => "Blog", - :link_url => "/blog", - :deletable => false, - :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1), - :menu_match => "^/blogs?(\/|\/.+?|)$" -) +if defined?(::Page) + page = ::Page.create( + :title => "Blog", + :link_url => "/blog", + :deletable => false, + :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1), + :menu_match => "^/blogs?(\/|\/.+?|)$" + ) -Page.default_parts.each do |default_page_part| - page.parts.create(:title => default_page_part, :body => nil) -end + ::Page.default_parts.each do |default_page_part| + page.parts.create(:title => default_page_part, :body => nil) + end +end \ No newline at end of file -- cgit v1.2.3