Class: GollumRails::Generators::ModelGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/gollum_rails/model/model_generator.rb

Overview

Generates models

Instance Method Summary collapse

Instance Method Details

#create_modelObject

generates a model


15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/gollum_rails/model/model_generator.rb', line 15

def create_model
  if ::File.exist? Rails.root.join("app", "models", "#{file_name}")
    raw = <<-EOM
    Warning: The file already exists
    EOM
    red raw
  else
    template "model_template.erb", "app/models/#{file_name}.rb"
  end
end