Class: MetaitemsGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



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

def self.next_migration_number(path)
  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

#add_controllerObject



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

def add_controller
  template 'metaitems_controller.rb', 'app/controllers/metaitems_controller.rb'
end

#add_helperObject



30
31
32
# File 'lib/generators/metaitems_generator.rb', line 30

def add_helper
  template 'metaitems_helper.rb', 'app/helpers/metaitems_helper.rb'
end

#add_migrationObject



21
22
23
# File 'lib/generators/metaitems_generator.rb', line 21

def add_migration
  migration_template 'migration.rb', 'db/migrate/create_metaitems'
end

#add_modelObject



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

def add_model
  template 'metaitem.rb', 'app/models/metaitem.rb'
end

#add_routeObject



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

def add_route
  route "resource :metaitem, :only => [:edit, :update]"
end

#add_viewObject



25
26
27
28
# File 'lib/generators/metaitems_generator.rb', line 25

def add_view
  source = options.playmo? ? 'playmo' : 'default'
  template "views/#{source}.html.erb", 'app/views/metaitems/edit.html.erb'
end