Sha256: 7c7598c7e67a5e0b9d4ce28dade7c56766a3cd347f54a179169f8f6e154fd06b

Contents?: true

Size: 785 Bytes

Versions: 21

Compression:

Stored size: 785 Bytes

Contents

require 'rails/generators/active_record'

module Migrant
  class Model < ActiveRecord::Generators::Base
    argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
    desc "The migrant:model generator creates a skeleton ActiveRecord model for use with Migrant."
    source_root File.expand_path("../templates", __FILE__)
    
    def create_model_file
      template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
    end
    
    hook_for :test_framework
    
    def protip
      puts "\nNow, go and edit app/models/#{file_name}.rb and/or generate more models, then run 'rake db:upgrade' to generate your schema."
    end

    protected
    def parent_class_name
      options[:parent] || "ActiveRecord::Base"
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
migrant-2.0.0 lib/generators/model.rb
migrant-2.0.0.pre lib/generators/model.rb
migrant-1.5.0 lib/generators/model.rb
migrant-1.4.3 lib/generators/model.rb
migrant-1.4.1 lib/generators/model.rb
migrant-1.4.0 lib/generators/model.rb
migrant-1.3.2 lib/generators/model.rb
migrant-1.3.1 lib/generators/model.rb
migrant-1.3.0 lib/generators/model.rb
migrant-1.2.8 lib/generators/model.rb
migrant-1.2.7 lib/generators/model.rb
migrant-1.2.5 lib/generators/model.rb
migrant-1.2.2 lib/generators/model.rb
migrant-1.2.1 lib/generators/model.rb
migrant-1.2.0 lib/generators/model.rb
migrant-1.1.2 lib/generators/model.rb
migrant-1.1.1 lib/generators/model.rb
migrant-1.1.0 lib/generators/model.rb
migrant-1.0.2 lib/generators/model.rb
migrant-1.0.1 lib/generators/model.rb