devise_invitable 1.7.5 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise_invitable might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.rdoc +98 -111
- data/app/controllers/devise/invitations_controller.rb +41 -40
- data/app/controllers/devise_invitable/registrations_controller.rb +11 -11
- data/app/views/devise/invitations/edit.html.erb +14 -8
- data/app/views/devise/invitations/new.html.erb +11 -7
- data/app/views/devise/mailer/invitation_instructions.html.erb +1 -1
- data/app/views/devise/mailer/invitation_instructions.text.erb +1 -1
- data/config/locales/ar.yml +23 -0
- data/config/locales/da.yml +41 -0
- data/config/locales/de.yml +31 -0
- data/config/locales/es.yml +31 -0
- data/config/locales/et.yml +23 -0
- data/config/locales/fa.yml +31 -0
- data/config/locales/fr.yml +34 -0
- data/config/locales/it.yml +31 -0
- data/config/locales/ja.yml +31 -0
- data/config/locales/ko.yml +24 -0
- data/config/locales/nl.yml +32 -0
- data/config/locales/no.yml +17 -0
- data/config/locales/pl.yml +31 -0
- data/config/locales/pt-BR.yml +23 -0
- data/config/locales/pt.yml +23 -0
- data/config/locales/ru.yml +23 -0
- data/config/locales/tr.yml +24 -0
- data/config/locales/ua.yml +31 -0
- data/config/locales/vi.yml +25 -0
- data/config/locales/zh-HK.yml +31 -0
- data/config/locales/zh-TW.yml +31 -0
- data/lib/devise_invitable.rb +5 -4
- data/lib/devise_invitable/controllers/helpers.rb +3 -4
- data/lib/devise_invitable/inviter.rb +4 -3
- data/lib/devise_invitable/mailer.rb +1 -1
- data/lib/devise_invitable/mapping.rb +6 -5
- data/lib/devise_invitable/models.rb +28 -28
- data/lib/devise_invitable/models/authenticatable.rb +7 -1
- data/lib/devise_invitable/parameter_sanitizer.rb +18 -18
- data/lib/devise_invitable/routes.rb +5 -5
- data/lib/devise_invitable/version.rb +1 -1
- data/lib/generators/active_record/devise_invitable_generator.rb +3 -3
- data/lib/generators/active_record/templates/migration.rb +0 -1
- data/lib/generators/devise_invitable/devise_invitable_generator.rb +4 -8
- data/lib/generators/devise_invitable/install_generator.rb +11 -14
- data/lib/generators/devise_invitable/templates/simple_form_for/invitations/edit.html.erb +10 -6
- data/lib/generators/devise_invitable/templates/simple_form_for/invitations/new.html.erb +10 -6
- data/lib/generators/devise_invitable/views_generator.rb +6 -6
- data/test/functional/registrations_controller_test.rb +24 -25
- data/test/generators/views_generator_test.rb +7 -6
- data/test/generators_test.rb +3 -2
- data/test/integration/invitation_remove_test.rb +8 -8
- data/test/integration/invitation_test.rb +46 -46
- data/test/integration_tests_helper.rb +8 -9
- data/test/model_tests_helper.rb +5 -5
- data/test/models/invitable_test.rb +120 -110
- data/test/models_test.rb +3 -3
- data/test/orm/active_record.rb +2 -2
- data/test/orm/mongoid.rb +2 -2
- data/test/rails_app/app/controllers/admins_controller.rb +4 -3
- data/test/rails_app/app/controllers/application_controller.rb +11 -10
- data/test/rails_app/app/controllers/free_invitations_controller.rb +12 -9
- data/test/rails_app/app/controllers/users_controller.rb +2 -2
- data/test/rails_app/app/models/admin.rb +7 -10
- data/test/rails_app/app/models/octopussy.rb +4 -4
- data/test/rails_app/app/models/user.rb +20 -20
- data/test/rails_app/app/views/admins/new.html.erb +9 -5
- data/test/rails_app/app/views/devise/sessions/new.html.erb +14 -6
- data/test/rails_app/app/views/free_invitations/new.html.erb +9 -5
- data/test/rails_app/app/views/layouts/application.html.erb +3 -4
- data/test/rails_app/app/views/users/invitations/new.html.erb +15 -9
- data/test/rails_app/config/application.rb +6 -6
- data/test/rails_app/config/boot.rb +2 -2
- data/test/rails_app/config/credentials.yml.enc +1 -0
- data/test/rails_app/config/initializers/devise.rb +4 -3
- data/test/rails_app/config/initializers/secret_token.rb +3 -1
- data/test/rails_app/config/initializers/session_store.rb +1 -1
- data/test/rails_app/config/initializers/wrap_parameters.rb +1 -1
- data/test/rails_app/config/master.key +1 -0
- data/test/rails_app/config/routes.rb +3 -3
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -2
- data/test/routes_test.rb +4 -4
- data/test/test_helper.rb +6 -19
- metadata +46 -22
@@ -1,10 +1,11 @@
|
|
1
1
|
module DeviseInvitable
|
2
2
|
module Mapping
|
3
3
|
private
|
4
|
-
|
5
|
-
options
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
|
5
|
+
def default_controllers(options)
|
6
|
+
options[:controllers] ||= {}
|
7
|
+
options[:controllers][:registrations] ||= 'devise_invitable/registrations'
|
8
|
+
super
|
9
|
+
end
|
9
10
|
end
|
10
11
|
end
|
@@ -10,15 +10,15 @@ module Devise
|
|
10
10
|
#
|
11
11
|
# Configuration:
|
12
12
|
#
|
13
|
-
# invite_for: The period the generated invitation token is valid
|
14
|
-
# this period, the invited resource won't be able to accept the invitation.
|
13
|
+
# invite_for: The period the generated invitation token is valid.
|
14
|
+
# After this period, the invited resource won't be able to accept the invitation.
|
15
15
|
# When invite_for is 0 (the default), the invitation won't expire.
|
16
16
|
#
|
17
17
|
# Examples:
|
18
18
|
#
|
19
19
|
# User.find(1).invited_to_sign_up? # => true/false
|
20
|
-
# User.invite!(:
|
21
|
-
# User.accept_invitation!(:
|
20
|
+
# User.invite!(email: 'someone@example.com') # => send invitation
|
21
|
+
# User.accept_invitation!(invitation_token: '...') # => accept invitation with a token
|
22
22
|
# User.find(1).accept_invitation! # => accept invitation
|
23
23
|
# User.find(1).invite! # => reset invitation status and send invitation again
|
24
24
|
module Invitable
|
@@ -31,34 +31,34 @@ module Devise
|
|
31
31
|
included do
|
32
32
|
include ::DeviseInvitable::Inviter
|
33
33
|
belongs_to_options = if Devise.invited_by_class_name
|
34
|
-
{:
|
34
|
+
{ class_name: Devise.invited_by_class_name }
|
35
35
|
else
|
36
|
-
{:
|
36
|
+
{ polymorphic: true }
|
37
37
|
end
|
38
38
|
if fk = Devise.invited_by_foreign_key
|
39
39
|
belongs_to_options[:foreign_key] = fk
|
40
40
|
end
|
41
41
|
if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && self < ActiveRecord::Base
|
42
42
|
counter_cache = Devise.invited_by_counter_cache
|
43
|
-
belongs_to_options.merge! :
|
44
|
-
belongs_to_options.merge! :
|
43
|
+
belongs_to_options.merge! counter_cache: counter_cache if counter_cache
|
44
|
+
belongs_to_options.merge! optional: true if ActiveRecord::VERSION::MAJOR >= 5
|
45
45
|
elsif defined?(Mongoid) && defined?(Mongoid::Document) && self < Mongoid::Document && Mongoid::VERSION >= '6.0.0'
|
46
|
-
belongs_to_options.merge! :
|
46
|
+
belongs_to_options.merge! optional: true
|
47
47
|
end
|
48
|
-
belongs_to :invited_by, belongs_to_options
|
48
|
+
belongs_to :invited_by, **belongs_to_options
|
49
49
|
|
50
50
|
extend ActiveModel::Callbacks
|
51
51
|
define_model_callbacks :invitation_created
|
52
52
|
define_model_callbacks :invitation_accepted
|
53
53
|
|
54
|
-
scope :no_active_invitation, lambda { where(:
|
54
|
+
scope :no_active_invitation, lambda { where(invitation_token: nil) }
|
55
55
|
if defined?(Mongoid) && defined?(Mongoid::Document) && self < Mongoid::Document
|
56
56
|
scope :created_by_invite, lambda { where(:invitation_created_at.ne => nil) }
|
57
|
-
scope :invitation_not_accepted, lambda { where(:
|
57
|
+
scope :invitation_not_accepted, lambda { where(invitation_accepted_at: nil, :invitation_token.ne => nil) }
|
58
58
|
scope :invitation_accepted, lambda { where(:invitation_accepted_at.ne => nil) }
|
59
59
|
else
|
60
60
|
scope :created_by_invite, lambda { where(arel_table[:invitation_created_at].not_eq(nil)) }
|
61
|
-
scope :invitation_not_accepted, lambda { where(arel_table[:invitation_token].not_eq(nil)).where(:
|
61
|
+
scope :invitation_not_accepted, lambda { where(arel_table[:invitation_token].not_eq(nil)).where(invitation_accepted_at: nil) }
|
62
62
|
scope :invitation_accepted, lambda { where(arel_table[:invitation_accepted_at].not_eq(nil)) }
|
63
63
|
|
64
64
|
callbacks = [
|
@@ -158,7 +158,7 @@ module Devise
|
|
158
158
|
self.downcase_keys if new_record_and_responds_to?(:downcase_keys)
|
159
159
|
self.strip_whitespace if new_record_and_responds_to?(:strip_whitespace)
|
160
160
|
|
161
|
-
if save(:
|
161
|
+
if save(validate: false)
|
162
162
|
self.invited_by.decrement_invitation_limit! if !was_invited and self.invited_by.present?
|
163
163
|
deliver_invitation(options) unless skip_invitation
|
164
164
|
end
|
@@ -274,7 +274,7 @@ module Devise
|
|
274
274
|
end
|
275
275
|
|
276
276
|
def generate_invitation_token!
|
277
|
-
generate_invitation_token && save(:
|
277
|
+
generate_invitation_token && save(validate: false)
|
278
278
|
end
|
279
279
|
|
280
280
|
def new_record_and_responds_to?(method)
|
@@ -298,7 +298,7 @@ module Devise
|
|
298
298
|
# email is resent unless resend_invitation is set to false.
|
299
299
|
# Attributes must contain the user's email, other attributes will be
|
300
300
|
# set in the record
|
301
|
-
def _invite(attributes={}, invited_by=nil, options = {}, &block)
|
301
|
+
def _invite(attributes = {}, invited_by = nil, options = {}, &block)
|
302
302
|
invite_key_array = invite_key_fields
|
303
303
|
attributes_hash = {}
|
304
304
|
invite_key_array.each do |k,v|
|
@@ -328,12 +328,12 @@ module Devise
|
|
328
328
|
[invitable, mail]
|
329
329
|
end
|
330
330
|
|
331
|
-
def invite!(attributes={}, invited_by=nil, options = {}, &block)
|
331
|
+
def invite!(attributes = {}, invited_by = nil, options = {}, &block)
|
332
332
|
attr_hash = ActiveSupport::HashWithIndifferentAccess.new(attributes.to_h)
|
333
333
|
_invite(attr_hash, invited_by, options, &block).first
|
334
334
|
end
|
335
335
|
|
336
|
-
def invite_mail!(attributes={}, invited_by=nil, options = {}, &block)
|
336
|
+
def invite_mail!(attributes = {}, invited_by = nil, options = {}, &block)
|
337
337
|
_invite(attributes, invited_by, options, &block).last
|
338
338
|
end
|
339
339
|
|
@@ -342,7 +342,7 @@ module Devise
|
|
342
342
|
# the record. If not user is found, returns a new user containing an
|
343
343
|
# error in invitation_token attribute.
|
344
344
|
# Attributes must contain invitation_token, password and confirmation
|
345
|
-
def accept_invitation!(attributes={})
|
345
|
+
def accept_invitation!(attributes = {})
|
346
346
|
original_token = attributes.delete(:invitation_token)
|
347
347
|
invitable = find_by_invitation_token(original_token, false)
|
348
348
|
if invitable.errors.empty?
|
@@ -391,15 +391,15 @@ module Devise
|
|
391
391
|
|
392
392
|
private
|
393
393
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
394
|
+
# The random password, as set after an invitation, must conform
|
395
|
+
# to any password format validation rules of the application.
|
396
|
+
# This default fixes the most common scenarios: Passwords must contain
|
397
|
+
# lower + upper case, a digit and a symbol.
|
398
|
+
# For more unusual rules, this method can be overridden.
|
399
|
+
def random_password
|
400
|
+
prefix = 'aA1!'
|
401
|
+
prefix + Devise.friendly_token(self.password_length.last-prefix.length)
|
402
|
+
end
|
403
403
|
end
|
404
404
|
end
|
405
405
|
end
|
@@ -1,11 +1,17 @@
|
|
1
1
|
module Devise
|
2
2
|
module Models
|
3
3
|
module Authenticatable
|
4
|
-
|
4
|
+
list = %i[
|
5
5
|
invitation_token invitation_created_at invitation_sent_at
|
6
6
|
invitation_accepted_at invitation_limit invited_by_type
|
7
7
|
invited_by_id invitations_count
|
8
8
|
]
|
9
|
+
|
10
|
+
if defined?(UNSAFE_ATTRIBUTES_FOR_SERIALIZATION)
|
11
|
+
UNSAFE_ATTRIBUTES_FOR_SERIALIZATION.concat(list)
|
12
|
+
else
|
13
|
+
BLACKLIST_FOR_SERIALIZATION.concat(list)
|
14
|
+
end
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
@@ -12,27 +12,27 @@ module DeviseInvitable
|
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
if defined?(Devise::BaseSanitizer)
|
16
|
+
def permit(keys)
|
17
|
+
default_params.permit(*Array(keys))
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
def attributes_for(kind)
|
21
|
+
case kind
|
22
|
+
when :invite
|
23
|
+
resource_class.respond_to?(:invite_key_fields) ? resource_class.invite_key_fields : []
|
24
|
+
when :accept_invitation
|
25
|
+
[:password, :password_confirmation, :invitation_token]
|
26
|
+
else
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
def initialize(resource_class, resource_name, params)
|
27
32
|
super
|
33
|
+
permit(:invite, keys: (resource_class.respond_to?(:invite_key_fields) ? resource_class.invite_key_fields : []) )
|
34
|
+
permit(:accept_invitation, keys: [:password, :password_confirmation, :invitation_token] )
|
28
35
|
end
|
29
36
|
end
|
30
|
-
else
|
31
|
-
def initialize(resource_class, resource_name, params)
|
32
|
-
super
|
33
|
-
permit(:invite, keys: (resource_class.respond_to?(:invite_key_fields) ? resource_class.invite_key_fields : []) )
|
34
|
-
permit(:accept_invitation, keys: [:password, :password_confirmation, :invitation_token] )
|
35
|
-
end
|
36
|
-
end
|
37
37
|
end
|
38
38
|
end
|
@@ -2,13 +2,13 @@ module ActionDispatch::Routing
|
|
2
2
|
class Mapper
|
3
3
|
|
4
4
|
protected
|
5
|
+
|
5
6
|
def devise_invitation(mapping, controllers)
|
6
|
-
resource :invitation, :
|
7
|
-
:
|
8
|
-
get :edit, :
|
9
|
-
get :destroy, :
|
7
|
+
resource :invitation, only: [:new, :create, :update],
|
8
|
+
path: mapping.path_names[:invitation], controller: controllers[:invitations] do
|
9
|
+
get :edit, path: mapping.path_names[:accept], as: :accept
|
10
|
+
get :destroy, path: mapping.path_names[:remove], as: :remove
|
10
11
|
end
|
11
12
|
end
|
12
|
-
|
13
13
|
end
|
14
14
|
end
|
@@ -3,14 +3,14 @@ require 'rails/generators/active_record'
|
|
3
3
|
module ActiveRecord
|
4
4
|
module Generators
|
5
5
|
class DeviseInvitableGenerator < ActiveRecord::Generators::Base
|
6
|
-
source_root File.expand_path(
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
7
|
|
8
8
|
def copy_devise_migration
|
9
|
-
migration_template
|
9
|
+
migration_template 'migration.rb', "db/migrate/devise_invitable_add_to_#{table_name}.rb", migration_version: migration_version
|
10
10
|
end
|
11
11
|
|
12
12
|
def migration_version
|
13
|
-
if Rails
|
13
|
+
if Rails::VERSION::MAJOR >= 5
|
14
14
|
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
15
15
|
end
|
16
16
|
end
|
@@ -8,7 +8,6 @@ class DeviseInvitableAddTo<%= table_name.camelize %> < ActiveRecord::Migration<%
|
|
8
8
|
t.integer :invitation_limit
|
9
9
|
t.references :invited_by, polymorphic: true
|
10
10
|
t.integer :invitations_count, default: 0
|
11
|
-
t.index :invitations_count
|
12
11
|
t.index :invitation_token, unique: true # for invitable
|
13
12
|
t.index :invited_by_id
|
14
13
|
end
|
@@ -1,17 +1,13 @@
|
|
1
1
|
module DeviseInvitable
|
2
2
|
module Generators
|
3
3
|
class DeviseInvitableGenerator < Rails::Generators::NamedBase
|
4
|
-
namespace
|
4
|
+
namespace 'devise_invitable'
|
5
5
|
|
6
|
-
desc
|
7
|
-
|
8
|
-
# def devise_generate_model
|
9
|
-
# invoke "devise", [name]
|
10
|
-
# end
|
6
|
+
desc 'Add :invitable directive in the given model. Also generate migration for ActiveRecord'
|
11
7
|
|
12
8
|
def inject_devise_invitable_content
|
13
|
-
path = File.join(
|
14
|
-
inject_into_file(path,
|
9
|
+
path = File.join('app', 'models', "#{file_path}.rb")
|
10
|
+
inject_into_file(path, 'invitable, :', after: 'devise :') if File.exists?(path)
|
15
11
|
end
|
16
12
|
|
17
13
|
hook_for :orm
|
@@ -1,26 +1,22 @@
|
|
1
1
|
module DeviseInvitable
|
2
2
|
module Generators
|
3
3
|
class InstallGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path(
|
5
|
-
desc
|
6
|
-
|
7
|
-
# def devise_install
|
8
|
-
# invoke "devise:install"
|
9
|
-
# end
|
4
|
+
source_root File.expand_path('../../templates', __FILE__)
|
5
|
+
desc 'Add DeviseInvitable config variables to the Devise initializer and copy DeviseInvitable locale files to your application.'
|
10
6
|
|
11
7
|
def add_config_options_to_initializer
|
12
|
-
devise_initializer_path =
|
8
|
+
devise_initializer_path = 'config/initializers/devise.rb'
|
13
9
|
if File.exist?(devise_initializer_path)
|
14
10
|
old_content = File.read(devise_initializer_path)
|
15
11
|
|
16
12
|
if old_content.match(Regexp.new(/^\s# ==> Configuration for :invitable\n/))
|
17
13
|
false
|
18
14
|
else
|
19
|
-
inject_into_file(devise_initializer_path, :
|
15
|
+
inject_into_file(devise_initializer_path, before: " # ==> Configuration for :confirmable\n") do
|
20
16
|
<<-CONTENT
|
21
17
|
# ==> Configuration for :invitable
|
22
|
-
# The period the generated invitation token is valid
|
23
|
-
# this period, the invited resource won't be able to accept the invitation.
|
18
|
+
# The period the generated invitation token is valid.
|
19
|
+
# After this period, the invited resource won't be able to accept the invitation.
|
24
20
|
# When invite_for is 0 (the default), the invitation won't expire.
|
25
21
|
# config.invite_for = 2.weeks
|
26
22
|
|
@@ -36,10 +32,11 @@ module DeviseInvitable
|
|
36
32
|
|
37
33
|
# The key to be used to check existing users when sending an invitation
|
38
34
|
# and the regexp used to test it when validate_on_invite is not set.
|
39
|
-
# config.invite_key = {:
|
40
|
-
# config.invite_key = {:
|
35
|
+
# config.invite_key = { email: /\\A[^@]+@[^@]+\\z/ }
|
36
|
+
# config.invite_key = { email: /\\A[^@]+@[^@]+\\z/, username: nil }
|
41
37
|
|
42
|
-
#
|
38
|
+
# Ensure that invited record is valid.
|
39
|
+
# The invitation won't be sent if this check fails.
|
43
40
|
# Default: false
|
44
41
|
# config.validate_on_invite = true
|
45
42
|
|
@@ -73,7 +70,7 @@ CONTENT
|
|
73
70
|
end
|
74
71
|
|
75
72
|
def copy_locale
|
76
|
-
copy_file
|
73
|
+
copy_file '../../../config/locales/en.yml', 'config/locales/devise_invitable.en.yml'
|
77
74
|
end
|
78
75
|
|
79
76
|
end
|
@@ -1,11 +1,15 @@
|
|
1
|
-
<h2><%= t
|
1
|
+
<h2><%= t "devise.invitations.edit.header" %></h2>
|
2
2
|
|
3
|
-
<%= simple_form_for
|
4
|
-
<%=
|
3
|
+
<%= simple_form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put }) do |f| %>
|
4
|
+
<%= f.error_notification %>
|
5
5
|
<%= f.hidden_field :invitation_token %>
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
<div class="form-inputs">
|
8
|
+
<%= f.input :password %>
|
9
|
+
<%= f.input :password_confirmation %>
|
10
|
+
</div>
|
9
11
|
|
10
|
-
|
12
|
+
<div class="form-actions">
|
13
|
+
<%= f.button :submit, t("devise.invitations.edit.submit_button") %>
|
14
|
+
</div>
|
11
15
|
<% end %>
|
@@ -1,11 +1,15 @@
|
|
1
1
|
<h2><%= t "devise.invitations.new.header" %></h2>
|
2
2
|
|
3
|
-
<%= simple_form_for
|
4
|
-
<%=
|
3
|
+
<%= simple_form_for(resource, as: resource_name, url: invitation_path(resource_name), html: { method: :post }) do |f| %>
|
4
|
+
<%= f.error_notification %>
|
5
5
|
|
6
|
-
<% resource.class.invite_key_fields.each do |field| -%>
|
7
|
-
|
8
|
-
|
6
|
+
<% resource.class.invite_key_fields.each do |field| -%>
|
7
|
+
<div class="form-inputs">
|
8
|
+
<%= f.input field %>
|
9
|
+
</div>
|
10
|
+
<% end -%>
|
9
11
|
|
10
|
-
|
12
|
+
<div class="form-actions">
|
13
|
+
<%= f.button :submit, t("devise.invitations.new.submit_button") %>
|
14
|
+
</div>
|
11
15
|
<% end %>
|
@@ -11,17 +11,17 @@ module DeviseInvitable
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class SimpleFormForGenerator < InvitationViewsGenerator
|
14
|
-
source_root File.expand_path(
|
14
|
+
source_root File.expand_path('../templates/simple_form_for', __FILE__)
|
15
15
|
end
|
16
16
|
|
17
17
|
class FormForGenerator < InvitationViewsGenerator
|
18
|
-
source_root File.expand_path(
|
18
|
+
source_root File.expand_path('../../../../app/views/devise', __FILE__)
|
19
19
|
end
|
20
20
|
|
21
21
|
class MailerViewsGenerator < Rails::Generators::Base
|
22
22
|
include ::Devise::Generators::ViewPathTemplates
|
23
|
-
source_root File.expand_path(
|
24
|
-
desc
|
23
|
+
source_root File.expand_path('../../../../app/views/devise', __FILE__)
|
24
|
+
desc 'Copies Devise mail erb views to your application.'
|
25
25
|
hide!
|
26
26
|
|
27
27
|
def copy_views
|
@@ -31,11 +31,11 @@ module DeviseInvitable
|
|
31
31
|
|
32
32
|
class ViewsGenerator < Rails::Generators::Base
|
33
33
|
desc 'Copies all DeviseInvitable views to your application.'
|
34
|
-
argument :scope, :
|
34
|
+
argument :scope, required: false, default: nil, desc: 'The scope to copy views to'
|
35
35
|
|
36
36
|
invoke MailerViewsGenerator
|
37
37
|
|
38
|
-
hook_for :form_builder, :
|
38
|
+
hook_for :form_builder, aliases: '-b', desc: 'Form builder to be used', default: defined?(SimpleForm) ? 'simple_form_for' : 'form_for'
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|