seeder.rb 879 B

1234567891011121314151617181920212223
  1. class Seeder
  2. def self.seed
  3. user = User.find_or_initialize_by(:email => ENV['SEED_EMAIL'] || "admin@example.com")
  4. if user.persisted?
  5. puts "User with email '#{user.email}' already exists, not seeding."
  6. exit
  7. end
  8. user.username = ENV['SEED_USERNAME'] || "admin"
  9. user.password = ENV['SEED_PASSWORD'] || "password"
  10. user.password_confirmation = ENV['SEED_PASSWORD'] || "password"
  11. user.invitation_code = User::INVITATION_CODES.first
  12. user.admin = true
  13. user.save!
  14. if DefaultScenarioImporter.seed(user)
  15. puts "NOTE: The example 'SF Weather Agent' will not work until you edit it and put in a free API key from http://www.wunderground.com/weather/api/"
  16. puts "See the Huginn Wiki for more Agent examples! https://github.com/cantino/huginn/wiki"
  17. else
  18. raise('Unable to import the default scenario')
  19. end
  20. end
  21. end