Created
January 17, 2014 09:06
-
-
Save marjinal1st/8470400 to your computer and use it in GitHub Desktop.
Generator
This file contains hidden or 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
require 'rails/generators' | |
require 'rails/generators/base' | |
require 'rails/generators/migration' | |
require 'rails/generators/active_record' | |
module Kebapress | |
module Generators | |
class InstallGenerator < Rails::Generators::NamedBase | |
source_root File.expand_path('../templates', __FILE__) | |
include Rails::Generators::Migration | |
desc 'Copies Kebapress views, migrations and locales.' | |
def copy_views | |
directory 'views', 'app/views' | |
end | |
def self.next_migration_number(dirname) | |
ActiveRecord::Generators::Base.next_migration_number(dirname) | |
end | |
def create_migration_file | |
migration_template 'migrations/categories.rb', 'db/migrate/create_kebapress_categories.rb' rescue nil | |
migration_template 'migrations/join_table_category_post.rb', 'db/migrate/create_kebapress_join_table_category_post.rb' rescue nil | |
migration_template 'migrations/join_table_post_tag.rb', 'db/migrate/create_kebapress_join_table_post_tag.rb' rescue nil | |
migration_template 'migrations/photos.rb', 'db/migrate/create_kebapress_photos.rb' rescue nil | |
migration_template 'migrations/posts.rb', 'db/migrate/create_kebapress_posts.rb' rescue nil | |
migration_template 'migrations/tags.rb', 'db/migrate/create_kebapress_tags.rb' rescue nil | |
end | |
def copy_locales | |
directory 'locales', 'config/locales' | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment