Class: PublishableGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_publishable_initializerObject

argument :class_name, :type => :string, :default => “article”



5
6
7
8
9
10
11
# File 'lib/generators/publishable/publishable_generator.rb', line 5

def create_publishable_initializer
  # create file for class
  template "app/models/publishable_model.rb.erb", "app/models/#{name.underscore}.rb"

  # create migration
  template "app/models/publishable_migration.rb.erb", "db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S").to_i}_create_#{ActiveSupport::Inflector.tableize(name)}.rb"
end