Class: EditableContentGenerator

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

Constant Summary collapse

MIGRATIONS_FILE =
File.join(File.dirname(__FILE__), "..", "..", "generators", "editable_content", "templates", "create_ec_contents.rb")

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Taken from ActiveRecord’s migration generator



25
26
27
28
29
30
31
# File 'lib/generators/editable_content_generator.rb', line 25

def self.next_migration_number(dirname) #:nodoc:
  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

#copy_files(*args) ⇒ Object

:nodoc:



20
21
22
# File 'lib/generators/editable_content_generator.rb', line 20

def copy_files(*args) #:nodoc:
  migration_template MIGRATIONS_FILE, "db/migrate/create_ec_contents.rb" unless options["skip-migration"]
end

#install_routes(*args) ⇒ Object

:nodoc:



13
14
15
16
17
18
# File 'lib/generators/editable_content_generator.rb', line 13

def install_routes(*args) #:nodoc:
  unless options["skip-routes"]
    route "get  '/contents/edit',   :as => :edit_content"
    route "post '/contents/update', :as => :update_content"
  end
end