Skip to content

Commit

Permalink
Merge pull request #43 from UCLALibrary/default_admin
Browse files Browse the repository at this point in the history
Add a default admin user
  • Loading branch information
ksclarke authored Aug 1, 2018
2 parents 42122e9 + 4b825b1 commit 6f69502
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"

# Include some handy rails tasks like db:seed
require 'capistrano/rails/collection'

# Load the SCM plugin appropriate to your project:
#
# require "capistrano/scm/hg"
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ group :development do
gem 'capistrano-ext'
gem 'capistrano-passenger'
gem 'capistrano-rails'
gem 'capistrano-rails-collection'
gem 'capistrano-sidekiq', '~> 0.20.0'
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'listen', '>= 3.0.5', '< 3.2'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ GEM
capistrano-rails (1.4.0)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rails-collection (0.1.0)
capistrano-rails (~> 1.1)
capistrano-sidekiq (0.20.0)
capistrano (>= 3.9.0)
sidekiq (>= 3.4)
Expand Down Expand Up @@ -817,6 +819,7 @@ DEPENDENCIES
capistrano-ext
capistrano-passenger
capistrano-rails
capistrano-rails-collection
capistrano-sidekiq (~> 0.20.0)
capybara (~> 2.13)
coffee-rails (~> 4.2)
Expand Down
4 changes: 4 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
end
end

# After the code has been deployed, run db:seed
# This creates the default admin user
after 'deploy:published', 'rails:rake:db:seed'

# Capistrano passenger restart isn't working consistently,
# so restart apache2 after a successful deploy, to ensure
# changes are picked up.
Expand Down
8 changes: 8 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
# Set up a default admin user
u = User.find_or_create_by(email: '[email protected]')
u.display_name = "Default Admin"
u.password = ENV['ADMIN_PASSWORD']
u.save
admin_role = Role.find_or_create_by(name: 'admin')
admin_role.users << u
admin_role.save

0 comments on commit 6f69502

Please sign in to comment.