Created
October 10, 2011 06:06
-
-
Save Prevole/1274717 to your computer and use it in GitHub Desktop.
Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/lib | |
/generators | |
/Amazing | |
/install | |
/install_generator.rb | |
/templates | |
/create_settings.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.