Class: Layered::Resource::Generators::ViewsGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/layered/resource/views/views_generator.rb

Overview

Copies the gem's view templates into the host app so they can be edited freely. The controller's view-resolution escape hatch picks them up automatically - no further wiring needed.

rails g layered:resource:views articles

Generates app/views/layered/articles/index,show,new,edit.html.erb.

Constant Summary collapse

VIEWS =
%w[index.html.erb show.html.erb new.html.erb edit.html.erb
_filters.html.erb _filter_control.html.erb].freeze

Instance Method Summary collapse

Instance Method Details

#copy_viewsObject



21
22
23
24
25
# File 'lib/generators/layered/resource/views/views_generator.rb', line 21

def copy_views
  VIEWS.each do |view|
    copy_file view, File.join("app/views/layered", resource_directory, view)
  end
end

#show_next_stepsObject



27
28
29
30
31
# File 'lib/generators/layered/resource/views/views_generator.rb', line 27

def show_next_steps
  say ""
  say "Edit any of the templates in app/views/layered/#{resource_directory}/ - the gem will use them in place of its defaults."
  say ""
end