Sha256: cdd8e9075dc48b1edfeee7f3011eeffc90620c5c54a7596c7b0a5563f9988626

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

# desc "Explaining what the task does"
# task :theblog do
#   # Task goes here
# end
namespace :theblog do
  desc "Create blog account"
  task :create_account, [:name, :email, :password, :role] => :environment do |task, args|
    account_attributes = args.to_hash

    password = account_attributes[:password] || "password"

    account = Theblog::Account.
      create! email: account_attributes[:email],
              user_name: account_attributes[:name],
              password: password,
              confirmed_at: Time.now

    role = account_attributes[:role] || :admin
    Theblog::Role.find_by(name: role).accounts << account

    puts "account with username #{account.user_name} and email #{account.email} created " \
         "and added to #{role} group"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
theblog-0.0.2.3 lib/tasks/theblog_tasks.rake
theblog-0.0.2.2 lib/tasks/theblog_tasks.rake
theblog-0.0.2.1 lib/tasks/theblog_tasks.rake