Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/generators/devise/controllers_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
module Devise
module Generators
class ControllersGenerator < Rails::Generators::Base
CONTROLLERS = %w(confirmations passwords registrations sessions unlocks omniauth_callbacks).freeze
CONTROLLERS = %w[confirmations passwords registrations sessions unlocks omniauth_callbacks].freeze

desc <<-DESC.strip_heredoc
Create inherited Devise controllers in your app/controllers folder.

Use -c to specify which controller you want to overwrite.
If you do no specify a controller, all controllers will be created.
If you do not specify a controller, all controllers will be created.
For example:

rails generate devise:controllers users -c=sessions
Expand All @@ -23,14 +23,14 @@ class Users::SessionsController < Devise::SessionsController
end
DESC

source_root File.expand_path("../../templates/controllers", __FILE__)
source_root File.expand_path('../../templates/controllers', __FILE__)
argument :scope, required: true,
desc: "The scope to create controllers in, e.g. users, admins"
class_option :controllers, aliases: "-c", type: :array,
desc: "Select specific controllers to generate (#{CONTROLLERS.join(', ')})"
desc: 'The scope to create controllers in, e.g. users, admins'
class_option :controllers, aliases: '-c', type: :array,
desc: "Select specific controllers to generate (#{CONTROLLERS.join(', ')})"

def create_controllers
@scope_prefix = scope.blank? ? '' : (scope.camelize + '::')
@scope_prefix = scope.blank? ? '' : "#{scope.camelize}::"
controllers = options[:controllers] || CONTROLLERS
controllers.each do |name|
template "#{name}_controller.rb",
Expand All @@ -39,7 +39,7 @@ def create_controllers
end

def show_readme
readme "README" if behavior == :invoke
readme 'README' if behavior == :invoke
end
end
end
Expand Down