Sha256: 4a6c940cbc4c4c7d18409031087ffe7f67a4587f38edec43c77b082130c4eeca

Contents?: true

Size: 1.51 KB

Versions: 5

Compression:

Stored size: 1.51 KB

Contents

require "generators/active_record/devise_generator"

module Identity
  class InstallGenerator < ActiveRecord::Generators::DeviseGenerator
    source_root File.expand_path("../templates", __FILE__)
    def config_file
      template "identity.rb", "config/initializers/identity.rb"
    end

    def model_contents
<<RUBY
  include Identity::Mixins::User
  #{"serialize :oauth_hash, JSON" unless json?}
RUBY
    end

    def migration_data
<<RUBY
      # To enable/disable users from admin area
      t.boolean :active,            null: false, default: true

      ## Database authenticatable
      t.string :email,              null: false, default: ""
      t.string :encrypted_password, null: false, default: ""

      ## Recoverable
      t.string   :reset_password_token
      t.datetime :reset_password_sent_at

      ## Rememberable
      t.datetime :remember_created_at

      ## Trackable
      t.integer  :sign_in_count, default: 0, null: false
      t.datetime :current_sign_in_at
      t.datetime :last_sign_in_at
      t.#{ip_column} :current_sign_in_ip
      t.#{ip_column} :last_sign_in_ip

      ## Confirmable
      t.string   :confirmation_token
      t.datetime :confirmed_at
      t.datetime :confirmation_sent_at
      t.string   :unconfirmed_email # Only if using reconfirmable

      ## Omniauthable
      t.string :provider
      t.string :uid
      t.#{json_column} :oauth_hash
RUBY
    end

    def json_column
      "%-6s" % (json? ? "json" : "text")
    end

    def json?
      rails4? && postgresql?
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
anadea-identity-0.5.4 lib/generators/identity/install_generator.rb
anadea-identity-0.5.3 lib/generators/identity/install_generator.rb
anadea-identity-0.5.2 lib/generators/identity/install_generator.rb
anadea-identity-0.5.1 lib/generators/identity/install_generator.rb
anadea-identity-0.5.0 lib/generators/identity/install_generator.rb