Class: Opinio::Generators::InstallGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/opinio/install/install_generator.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) next_migration_number(dirname)



29
30
31
32
33
34
35
# File 'lib/generators/opinio/install/install_generator.rb', line 29

def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    Time.now.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

- (Object) add_dependency_gem



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

def add_dependency_gem
  gem "kaminari"
end

- (Object) generate_initializer



17
18
19
# File 'lib/generators/opinio/install/install_generator.rb', line 17

def generate_initializer
  template "initializers/opinio.erb", "config/initializers/opinio.rb"
end

- (Object) generate_migration



13
14
15
# File 'lib/generators/opinio/install/install_generator.rb', line 13

def generate_migration
  migration_template "migrations/create_model.rb", "db/migrate/create_#{table_name}", {:assigns => {:name => name, :table_name => table_name}}
end

- (Object) generate_model



9
10
11
# File 'lib/generators/opinio/install/install_generator.rb', line 9

def generate_model
  template "models/model.rb", "app/models/#{file_name}.rb"
end

- (Object) generate_route



21
22
23
# File 'lib/generators/opinio/install/install_generator.rb', line 21

def generate_route
  route "opinio_model"
end