Class: EtHistory::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/et_history/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



38
39
40
# File 'lib/generators/et_history/install_generator.rb', line 38

def self.next_migration_number(dirname)
  ::ActiveRecord::Generators::Base.next_migration_number(dirname)
end

Instance Method Details

#create_controller_fileObject



16
17
18
# File 'lib/generators/et_history/install_generator.rb', line 16

def create_controller_file
  template('history_controller.rb', "app/controllers/history_controller.rb")
end

#create_initializerObject



29
30
31
# File 'lib/generators/et_history/install_generator.rb', line 29

def create_initializer
  template('paper_trail.rb', "config/initializers/paper_trail.rb")
end

#create_migration_fileObject



12
13
14
# File 'lib/generators/et_history/install_generator.rb', line 12

def create_migration_file
  migration_template 'create_versions.rb', 'db/migrate/create_versions.rb'
end

#create_model_fileObject



25
26
27
# File 'lib/generators/et_history/install_generator.rb', line 25

def create_model_file
  template('version.rb', "app/models/version.rb")
end

#create_routes_entryObject



34
35
36
# File 'lib/generators/et_history/install_generator.rb', line 34

def create_routes_entry
  route 'resources :history, only: :index'
end

#create_view_fileObject



20
21
22
23
# File 'lib/generators/et_history/install_generator.rb', line 20

def create_view_file
  directory('history/', 'app/views/history')
  # template('history_index.html.erb', "app/views/history/index.html.erb")
end