Permalink
Browse files

Add generator for authem:model

  • Loading branch information...
1 parent 4389231 commit 32dfea61df5b589d66911771011ac79d6cb5bcb3 Micah Cooper and Travis Anderson committed with Hashrocket Workstation Sep 26, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 lib/generators/authem/model/model_generator.rb
@@ -0,0 +1,23 @@
+require 'rails/generators/base'
+
+module Authem
+ class ModelGenerator < Rails::Generators::Base
+
+ argument :model_name, type: :string, default: "user"
+
+ def generate_model
+ generate("model #{model_name} email:string, password_digest:string, reset_password_token:string, session_token:string")
+ end
+
+ def update_model_to_include_authem
+ insert_into_file "app/models/#{model_name}.rb", "\n include Authem::User\n\n", after: "class #{model_name.camelize} < ActiveRecord::Base\n"
+ end
+
+ def add_initializer
+ create_file 'config/initializers/authem.rb' do
+ %Q(Authem.configure do |config|\n config.user_class = #{model_name.camelize}\nend)
+ end
+ end
+
+ end
+end

0 comments on commit 32dfea6

Please sign in to comment.