diff options
author | Philip Arndt <parndt@gmail.com> | 2011-04-27 22:17:30 -0700 |
---|---|---|
committer | Philip Arndt <parndt@gmail.com> | 2011-04-27 22:17:30 -0700 |
commit | 03e105b9e061ca658e0c8f3a3a05378390be4218 (patch) | |
tree | 7ed83bda6679acdf578460e9bf6060008360692b /db | |
parent | 1f72e3d90a1e8678de4a4b658b6675d2597d857c (diff) | |
download | refinerycms-blog-03e105b9e061ca658e0c8f3a3a05378390be4218.tar.gz refinerycms-blog-03e105b9e061ca658e0c8f3a3a05378390be4218.tar.bz2 refinerycms-blog-03e105b9e061ca658e0c8f3a3a05378390be4218.zip |
Ensure that the seeds don't blow up when either 'User' or 'Page' are not defined.
Diffstat (limited to 'db')
-rw-r--r-- | db/seeds/refinerycms_blog.rb | 26 |
1 files 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 |