class Layout::Generators::DeviseGenerator

Public Instance Methods

add_devise_views() click to toggle source
# File lib/generators/layout/devise/devise_generator.rb, line 11
def add_devise_views
  copy_file 'sessions/new.html.erb', 'app/views/devise/sessions/new.html.erb'
  copy_file 'passwords/new.html.erb', 'app/views/devise/passwords/new.html.erb'
  copy_file 'passwords/edit.html.erb', 'app/views/devise/passwords/edit.html.erb'
  unless File.exists?('app/views/devise/registrations/new.html.erb')
    copy_file 'registrations/new.html.erb', 'app/views/devise/registrations/new.html.erb'
  end
  copy_file 'registrations/edit.html.erb', 'app/views/devise/registrations/edit.html.erb'
end
add_name_field() click to toggle source
# File lib/generators/layout/devise/devise_generator.rb, line 21
def add_name_field
  if Object.const_defined?('User')
    if User.column_names.include? 'name'
      gsub_file 'app/views/devise/registrations/new.html.erb', /:autofocus => true, /, ''
      gsub_file 'app/views/devise/registrations/edit.html.erb', /:autofocus => true, /, ''
      inject_into_file 'app/views/devise/registrations/new.html.erb', name_field, :before => "      <%= f.label :email %>"
      inject_into_file 'app/views/devise/registrations/edit.html.erb', name_field, :before => "      <%= f.label :email %>"
    end
  end
end

Private Instance Methods

name_field() click to toggle source
# File lib/generators/layout/devise/devise_generator.rb, line 34
      def name_field
<<-TEXT
      <%= f.label :name %>
      <%= f.text_field :name, :autofocus => true, class: 'form-control' %>
    </div>
    <div class="form-group">
TEXT
      end