Sha256: 79f3034f6dad4c0e364363b43c706b531b434ea2520d8775445a80857d6de21b
Contents?: true
Size: 819 Bytes
Versions: 6
Compression:
Stored size: 819 Bytes
Contents
require 'rails/generators/active_record' class CounterCultureGenerator < ActiveRecord::Generators::Base desc "Create a migration that adds counter-cache columns to a model" argument :counter_cache_columns, :required => true, :type => :array, :desc => "The names of the counter cache columns to add", :banner => "counter_cache_one counter_cache_two counter_cache_three ..." source_root File.expand_path("../templates", __FILE__) def generate_migration migration_template "counter_culture_migration.rb.erb", "db/migrate/#{migration_file_name}" end protected def migration_name "add_#{counter_cache_columns.join("_")}_to_#{name.underscore.pluralize}" end def migration_file_name "#{migration_name}.rb" end def migration_class_name migration_name.camelize end end
Version data entries
6 entries across 6 versions & 1 rubygems