Module: Devise::Generators::ViewPathTemplates
- Extended by:
- ActiveSupport::Concern
- Included in:
- ErbGenerator, FormForGenerator, MarkerbGenerator, SharedViewsGenerator, SimpleFormForGenerator
- Defined in:
- lib/generators/devise/views_generator.rb
Overview
Include this module in your generator to generate Devise views. ‘copy_views` is the main method and by default copies all views with forms.
Instance Method Summary collapse
- #copy_views ⇒ Object
- #plural_scope ⇒ Object protected
- #target_path ⇒ Object protected
- #view_directory(name, _target_path = nil) ⇒ Object protected
Instance Method Details
#copy_views ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/devise/views_generator.rb', line 26 def copy_views if [:views] [:views].each do |directory| view_directory directory.to_sym end else view_directory :confirmations view_directory :passwords view_directory :registrations view_directory :sessions view_directory :unlocks end end |
#plural_scope ⇒ Object (protected)
56 57 58 |
# File 'lib/generators/devise/views_generator.rb', line 56 def plural_scope @plural_scope ||= scope.presence && scope.underscore.pluralize end |
#target_path ⇒ Object (protected)
52 53 54 |
# File 'lib/generators/devise/views_generator.rb', line 52 def target_path @target_path ||= "app/views/#{plural_scope || :devise}" end |
#view_directory(name, _target_path = nil) ⇒ Object (protected)
42 43 44 45 46 47 48 49 50 |
# File 'lib/generators/devise/views_generator.rb', line 42 def view_directory(name, _target_path = nil) directory name.to_s, _target_path || "#{target_path}/#{name}" do |content| if scope content.gsub("devise/shared", "#{plural_scope}/shared") else content end end end |