Class: Postnhost::Generators::UserGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/postnhost/user/user_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_userObject

Raises:

  • (Thor::Error)


6
7
8
9
10
11
12
13
14
# File 'lib/generators/postnhost/user/user_generator.rb', line 6

def create_user
  attributes = prompt_for_user_attributes
  raise Thor::Error, "Passwords do not match." unless matching_passwords?(attributes)

  user = Postnhost::User.new(attributes)
  raise Thor::Error, user.errors.full_messages.to_sentence unless user.save

  say("Created CMS user #{user.email}.", :green)
end