Commit 308c6539 authored by Alec Leamas's avatar Alec Leamas
Browse files

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
Loading
Loading
Loading
Loading
+18 −24
Original line number Diff line number Diff line
@@ -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,13 +44,7 @@ else
    email = ARGS[:email]
end

if ARGS[:password] == nil
    password = read_password
else
    password = ARGS[:password]
end

#printf "Building: %s, %s, '%s'\n", username, email, password
password = (ARGS[:password] == nil ? read_password : ARGS[:password])

user = User.build( :email => email,
                   :username => username,
+0 −9
Original line number Diff line number Diff line
@@ -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'