Skip to content

Commit

Permalink
Modernize the seed file and provide protection for when there is no U…
Browse files Browse the repository at this point in the history
…ser model or when the User exists and already has the plugin added to their list somehow.
  • Loading branch information
parndt committed May 16, 2011
1 parent a5d753f commit 2b113c2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/generators/templates/db/seeds/image_rotators.rb
@@ -1,4 +1,8 @@
User.find(:all).each do |user|
user.plugins.create(:name => "image_rotators",
:position => (user.plugins.maximum(:position) || -1) +1)
if defined?(::User)
User.find(:all).each do |user|
if user.plugins.where(:name => 'image_rotators').blank?
user.plugins.create(:name => "image_rotators",
:position => (user.plugins.maximum(:position) || -1) +1)
end
end
end

0 comments on commit 2b113c2

Please sign in to comment.