recipes/init.rb in intersect_rails_composer-0.0.2 vs recipes/init.rb in intersect_rails_composer-0.0.4

- old
+ new

@@ -20,13 +20,23 @@ append_file 'config/application.yml', credentials if prefs[:local_env_file] if prefs[:local_env_file] ## DEFAULT USER unless prefer :starter_app, false append_file 'config/application.yml' do <<-FILE -ADMIN_NAME: First User -ADMIN_EMAIL: user@example.com -ADMIN_PASSWORD: changeme +users: + - admin: + name: Test User 1 + email: test@intersect.org.au + password: Pass.123 + - user: + name: Test User 2 + email: test2@intersect.org.au + password: Pass.123 + - user: + name: Test User 3 + email: test3@intersect.org.au + password: Pass.123 FILE end end ## AUTHENTICATION if prefer :authentication, 'omniauth' @@ -36,11 +46,11 @@ FILE end end ## AUTHORIZATION if (prefer :authorization, 'cancan') - append_file 'config/application.yml', "ROLES: [admin, user, VIP]\n" + append_file 'config/application.yml', "ROLES: [admin, user]\n" end end ### SUBDOMAINS ### copy_from_repo 'config/application.yml', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app' ### APPLICATION.EXAMPLE.YML ### @@ -80,11 +90,15 @@ end ## DEVISE-DEFAULT if prefer :authentication, 'devise' append_file 'db/seeds.rb' do <<-FILE puts 'DEFAULT USERS' -user = User.find_or_create_by_email :name => ENV['ADMIN_NAME'].dup, :email => ENV['ADMIN_EMAIL'].dup, :password => ENV['ADMIN_PASSWORD'].dup, :password_confirmation => ENV['ADMIN_PASSWORD'].dup -puts 'user: ' << user.name +application = YAML.load_file Rails.root.join('config/application.yml') +application['users'].each do |user| + type = user.first[0] + u = User.find_or_create_by_email name: user['name'], email: user['email'], password: user['password'], password_confirmation: user['password'] + u.add_role type.to_sym +end FILE end # Mongoid doesn't have a 'find_or_create_by' method gsub_file 'db/seeds.rb', /find_or_create_by_email/, 'create!' if prefer :orm, 'mongoid' end