Class: Tableview::Generators::TableviewGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/tableview/tableview_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_partialObject



8
9
10
11
12
13
14
15
# File 'lib/generators/tableview/tableview_generator.rb', line 8

def create_partial
  cols = file_name.camelize.constantize.column_names
  template = "=> @#{file_name.tableize}\n\n"
  cols.each do |col|
    template << "+ :#{col}\n"
  end
  create_file "app/views/#{file_name.tableize}/_table.tv", template
end

#install_into_controllerObject



17
18
19
# File 'lib/generators/tableview/tableview_generator.rb', line 17

def install_into_controller
  inject_into_class "app/controllers/#{file_name.tableize}_controller.rb", file_name.camelize.pluralize + "Controller", "  self.responder = ApplicationResponder\n  respond_to :html, :json, :csv, :xls, :ascii"
end