Sha256: 5f40562893ba4afa58f84651715378f92fa07b2a9c0cfa4863e6293508bac365

Contents?: true

Size: 885 Bytes

Versions: 1

Compression:

Stored size: 885 Bytes

Contents

require 'rake'
require 'rails/generators'

module Heartwood
  class UserGenerator < Rails::Generators::Base

    desc "Create a new user for your app."

    source_root File.expand_path('../../templates', __FILE__)

    class_option(
      :admin,
      :type => :boolean,
      :default => false,
      :description => "Make the user an admin"
    )

    argument :email, :type => :string
    argument :password, :type => :string

    # Create a user with the provided credentials
    def create_user
      if options.admin == true
        User.create!(
          :email => email,
          :password => password,
          :password_confirmation => password,
          :is_admin => options.admin
        )
      else
        User.create!(
          :email => email,
          :password => password,
          :password_confirmation => password
        )
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heartwood-0.0.1 lib/generators/cambium/user_generator.rb