Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generator
class CreateSettings < ActiveRecord::Migration
def up
create_table :settings do |t|
t.string :paramkey, :limit => 255, :null => false
t.string :paramvalue, :limit => 1000
t.string :i18nkey, :limit => 35, :null => false
t.string :paramtype, :limit => 25
t.timestamps
end
change_table :settings do |t|
t.index :paramkey, :unique => true
end
end
def down
change_table :settings do |t|
t.remove_index :paramkey
end
drop_table :settings
end
end
module Amazing
class InstallGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path("../templates", __FILE__)
def install
puts "Here we are in the plugin generator."
migration_template "create_settings.rb", "db/migrate/create_settings.rb"
end
private
def self.next_migration_number(number)
ActiveRecord::Migration.new().next_migration_number 0
end
end
end
/lib
/generators
/Amazing
/install
/install_generator.rb
/templates
/create_settings.rb
@Prevole

This comment has been minimized.

Copy link
Owner Author

Prevole commented Oct 10, 2011

Rails commands:

veytmbp:AppTester prevole $ rails g
Usage: rails generate GENERATOR [args] [options]

General options:
-h, [--help] # Print generator's options and usage
-p, [--pretend] # Run but do not make any changes
-f, [--force] # Overwrite files that already exist
-s, [--skip] # Skip files that already exist
-q, [--quiet] # Suppress status output

Please choose a generator below.

Rails:
assets
controller
generator
helper
integration_test
mailer
migration
model
observer
performance_test
plugin
resource
scaffold
scaffold_controller
session_migration

Amazing:
amazing:install

Coffee:
coffee:assets

Formtastic:
formtastic:install

Jquery:
jquery:install

Js:
js:assets

pveytmbp:AppTester prevole $ rails g amazing:install
Could not find generator amazing:install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.