Class: Curly::Generators::ControllerGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/curly/controller/controller_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_view_filesObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/generators/curly/controller/controller_generator.rb', line 11

def create_view_files
  base_views_path = File.join("app/views", class_path, file_name)
  base_presenters_path = File.join("app/presenters", class_path, file_name)

  empty_directory base_views_path
  empty_directory base_presenters_path

  actions.each do |action|
    @view_path = File.join(base_views_path, "#{action}.html.curly")
    @presenter_path = File.join(base_presenters_path, "#{action}_presenter.rb")
    @action = action
    @presenter_name = "#{class_name}::#{action.capitalize}Presenter"

    template "view.html.curly.erb", @view_path
    template "presenter.rb.erb", @presenter_path
  end
end