Module: Devise::Generators::OrmHelpers

Included in:
ActiveRecord::Generators::DeviseGenerator, Mongoid::Generators::DeviseGenerator
Defined in:
lib/generators/devise/orm_helpers.rb

Instance Method Summary collapse

Instance Method Details

#model_contentsObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/devise/orm_helpers.rb', line 4

def model_contents
  buffer = <<-CONTENT
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
   :recoverable, :rememberable, :trackable, :validatable

CONTENT
  buffer += <<-CONTENT if needs_attr_accessible?
  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me

CONTENT
  buffer
end

#needs_attr_accessible?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/generators/devise/orm_helpers.rb', line 20

def needs_attr_accessible?
  rails_3? && !strong_parameters_enabled?
end

#rails_3?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/generators/devise/orm_helpers.rb', line 24

def rails_3?
  Rails::VERSION::MAJOR == 3
end

#strong_parameters_enabled?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/generators/devise/orm_helpers.rb', line 28

def strong_parameters_enabled?
  defined?(ActionController::StrongParameters)
end