Class: Importable::ViewsGenerator

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

Instance Method Summary collapse

Instance Method Details

#copy_view_filesObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/importable/views/views_generator.rb', line 6

def copy_view_files

  files = %w[
    _errors
    _extras
    spreadsheets/_actions
    spreadsheets/_choose_worksheet_step
    spreadsheets/_upload_file_step
    spreadsheets/new
    spreadsheets/show
    resources/_actions
    resources/new
    resources/show
  ]

  files.each do |file|
    from_path = "#{file}.html.erb"
    path_parts = []
    path_parts.unshift("importable/#{file}.html.erb")
    # include the name as a namespace if it's not blank
    path_parts.unshift(name) unless name.blank?
    to_path = File.join('app/views', *path_parts)
    copy_file from_path, to_path
  end
end