Cleaning up db:first_user patch.
Removing duplicated reset task (what happened?). Hate long lines. Let user.rb handle all error checks. Clean up.
This commit is contained in:
parent
c3356af8d1
commit
308c653945
2 changed files with 18 additions and 33 deletions
|
|
@ -5,9 +5,13 @@
|
|||
# Add a parameterized user to database.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
config_path = File.join (File.dirname(__FILE__), '..', '..', 'config')
|
||||
|
||||
require File.join(config_path, 'environment')
|
||||
require File.join(config_path, 'initializers', '_load_app_config.rb')
|
||||
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')
|
||||
require File.join(File.dirname(__FILE__), '..', '..','config', 'initializers', '_load_app_config.rb')
|
||||
require 'yaml'
|
||||
|
||||
def read_password
|
||||
|
|
@ -18,10 +22,6 @@ def read_password
|
|||
printf 'Enter password: '
|
||||
pw1 = $stdin.gets.chomp
|
||||
puts
|
||||
if pw1.length < 6
|
||||
puts "Too short (minimum 6 characters)"
|
||||
next
|
||||
end
|
||||
printf 'Again: '
|
||||
pw2 = $stdin.gets.chomp
|
||||
puts
|
||||
|
|
@ -44,25 +44,19 @@ else
|
|||
email = ARGS[:email]
|
||||
end
|
||||
|
||||
if ARGS[:password] == nil
|
||||
password = read_password
|
||||
else
|
||||
password = ARGS[:password]
|
||||
end
|
||||
password = (ARGS[:password] == nil ? read_password : ARGS[:password])
|
||||
|
||||
#printf "Building: %s, %s, '%s'\n", username, email, password
|
||||
|
||||
user = User.build( :email => email,
|
||||
:username => username,
|
||||
:password => password,
|
||||
:password_confirmation => password,
|
||||
:person => {
|
||||
:profile => {
|
||||
:first_name => username,
|
||||
:last_name => "Unknown",
|
||||
:image_url => "/images/user/default.png"
|
||||
}
|
||||
}
|
||||
user = User.build( :email => email,
|
||||
:username => username,
|
||||
:password => password,
|
||||
:password_confirmation => password,
|
||||
:person => {
|
||||
:profile => {
|
||||
:first_name => username,
|
||||
:last_name => "Unknown",
|
||||
:image_url => "/images/user/default.png"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
errors = user.errors
|
||||
|
|
|
|||
|
|
@ -59,13 +59,6 @@ namespace :db do
|
|||
puts "you did it!"
|
||||
end
|
||||
|
||||
task :reset do
|
||||
puts "making a new base user"
|
||||
Rake::Task['db:purge'].invoke
|
||||
Rake::Task['db:seed:dev'].invoke
|
||||
puts "you did it!"
|
||||
end
|
||||
|
||||
desc 'Purge database, add a new user'
|
||||
task :first_user, :username, :password do |t, args|
|
||||
puts "Purging database and adding a new user"
|
||||
|
|
@ -75,8 +68,6 @@ namespace :db do
|
|||
Rake::Task['db:seed:first_user'].invoke(username, password)
|
||||
end
|
||||
|
||||
|
||||
|
||||
task :fix_diaspora_handle do
|
||||
puts "fixing the people in this seed"
|
||||
require File.dirname(__FILE__) + '/../../config/environment'
|
||||
|
|
|
|||
Loading…
Reference in a new issue