Skip to content
Extraits de code Groupes Projets
Valider 308c6539 rédigé par Alec Leamas's avatar Alec Leamas
Parcourir les fichiers

Cleaning up db:first_user patch.

Removing duplicated reset task (what happened?). Hate long lines.
Let user.rb handle all error checks. Clean up.
parent c3356af8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -5,9 +5,13 @@ ...@@ -5,9 +5,13 @@
# Add a parameterized user to database. # 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' require 'yaml'
def read_password def read_password
...@@ -18,10 +22,6 @@ def read_password ...@@ -18,10 +22,6 @@ def read_password
printf 'Enter password: ' printf 'Enter password: '
pw1 = $stdin.gets.chomp pw1 = $stdin.gets.chomp
puts puts
if pw1.length < 6
puts "Too short (minimum 6 characters)"
next
end
printf 'Again: ' printf 'Again: '
pw2 = $stdin.gets.chomp pw2 = $stdin.gets.chomp
puts puts
...@@ -44,25 +44,19 @@ else ...@@ -44,25 +44,19 @@ else
email = ARGS[:email] email = ARGS[:email]
end end
if ARGS[:password] == nil password = (ARGS[:password] == nil ? read_password : ARGS[:password])
password = read_password
else
password = ARGS[:password]
end
#printf "Building: %s, %s, '%s'\n", username, email, password
user = User.build( :email => email, user = User.build( :email => email,
:username => username, :username => username,
:password => password, :password => password,
:password_confirmation => password, :password_confirmation => password,
:person => { :person => {
:profile => { :profile => {
:first_name => username, :first_name => username,
:last_name => "Unknown", :last_name => "Unknown",
:image_url => "/images/user/default.png" :image_url => "/images/user/default.png"
} }
} }
) )
errors = user.errors errors = user.errors
......
...@@ -59,13 +59,6 @@ namespace :db do ...@@ -59,13 +59,6 @@ namespace :db do
puts "you did it!" puts "you did it!"
end 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' desc 'Purge database, add a new user'
task :first_user, :username, :password do |t, args| task :first_user, :username, :password do |t, args|
puts "Purging database and adding a new user" puts "Purging database and adding a new user"
...@@ -75,8 +68,6 @@ namespace :db do ...@@ -75,8 +68,6 @@ namespace :db do
Rake::Task['db:seed:first_user'].invoke(username, password) Rake::Task['db:seed:first_user'].invoke(username, password)
end end
task :fix_diaspora_handle do task :fix_diaspora_handle do
puts "fixing the people in this seed" puts "fixing the people in this seed"
require File.dirname(__FILE__) + '/../../config/environment' require File.dirname(__FILE__) + '/../../config/environment'
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter