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
|
# File 'lib/generators/selections_scaffold/selections_scaffold_generator.rb', line 14
def generate_selections_scaffold
{
'selection_spec.rb' => 'spec/models/',
'selections_controller_spec.rb' => 'spec/controllers/',
'selections_controller.rb' => 'app/controllers/',
'selections_helper.rb' => 'app/helpers/',
'selections.yml' => 'spec/fixtures/',
'_form.html.haml' => 'app/views/selections/',
'edit.html.haml' => 'app/views/selections/',
'index.html.haml' => 'app/views/selections/',
'new.html.haml' => 'app/views/selections/'
}.each_pair do |file, dir|
copy_file file, dir + file
end
model_source =
if ActiveRecord::VERSION::MAJOR >= 4
'selection.rb'
else
'selection_rails3.rb'
end
copy_file model_source, 'app/models/selection.rb'
migration_template 'create_selections.rb', 'db/migrate/create_selections.rb'
route 'resources(:selections, only: :index) { resources :selections, except: :show }'
end
|