Class: DeviseInvitable::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- DeviseInvitable::Generators::InstallGenerator
- Defined in:
- lib/generators/devise_invitable/install_generator.rb
Instance Method Summary collapse
-
#add_config_options_to_initializer ⇒ Object
def devise_install invoke “devise:install” end.
- #copy_locale ⇒ Object
Instance Method Details
#add_config_options_to_initializer ⇒ Object
def devise_install
invoke "devise:install"
end
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/generators/devise_invitable/install_generator.rb', line 11 def devise_initializer_path = "config/initializers/devise.rb" if File.exist?(devise_initializer_path) old_content = File.read(devise_initializer_path) if old_content.match(Regexp.new(/^\s# ==> Configuration for :invitable\n/)) false else inject_into_file(devise_initializer_path, :before => " # ==> Configuration for :confirmable\n") do <<-CONTENT # ==> Configuration for :invitable # The period the generated invitation token is valid, after # this period, the invited resource won't be able to accept the invitation. # When invite_for is 0 (the default), the invitation won't expire. # config.invite_for = 2.weeks # Number of invitations users can send. # - If invitation_limit is nil, there is no limit for invitations, users can # send unlimited invitations, invitation_limit column is not used. # - If invitation_limit is 0, users can't send invitations by default. # - If invitation_limit n > 0, users can send n invitations. # You can change invitation_limit column for some users so they can send more # or less invitations, even with global invitation_limit = 0 # Default: nil # config.invitation_limit = 5 # The key to be used to check existing users when sending an invitation # and the regexp used to test it when validate_on_invite is not set. # config.invite_key = {:email => /\A[^@]+@[^@]+\z/} # config.invite_key = {:email => /\A[^@]+@[^@]+\z/, :username => nil} # Flag that force a record to be valid before being actually invited # Default: false # config.validate_on_invite = true CONTENT end end end end |
#copy_locale ⇒ Object
52 53 54 |
# File 'lib/generators/devise_invitable/install_generator.rb', line 52 def copy_locale copy_file "../../../config/locales/en.yml", "config/locales/devise_invitable.en.yml" end |