9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/generators/controller_generator.rb', line 9
def generate_files
underscored = controller_name.underscore
path = 'app/controllers/'
view_path = "app/views/#{underscored.pluralize}/show.html.haml"
route = underscored.gsub(/\//,'#')
underscored = underscored.pluralize + '_controller' unless underscored.match(/_controller$/)
@class_name = underscored.classify
@model_name = @class_name.demodulize.match(/(.+)Controller$/)[1].underscore.singularize
file_path = "#{path}#{underscored}.rb"
css_path = "public/stylesheets/#{underscored.split("_").first}.css"
template('controller.rb', file_path)
template('view.rb',view_path)
template('style.rb',css_path)
route("resource :#{route}, :only => :show")
end
|