Class: AddDefaultUser

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/marilyn/fish/db/migrate/add_default_user.rb

Constant Summary collapse

DEFAULT_ADMIN_EMAIL =
'[email protected]'
DEFAULT_ADMIN_PASSWORD =
'admin_,tt'

Class Method Summary collapse

Class Method Details

.downObject



13
14
15
16
# File 'lib/generators/marilyn/fish/db/migrate/add_default_user.rb', line 13

def self.down
  admin = User.find_by_email(DEFAULT_ADMIN_EMAIL)
  admin.delete if admin
end

.upObject



5
6
7
8
9
10
11
# File 'lib/generators/marilyn/fish/db/migrate/add_default_user.rb', line 5

def self.up
  return if User.find_by_email(DEFAULT_ADMIN_EMAIL)

  admin = User.create(:email => DEFAULT_ADMIN_EMAIL,
                      :password => DEFAULT_ADMIN_PASSWORD)
  admin.save
end