Class: Kea::ModelGenerator

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

Instance Method Summary collapse

Instance Method Details

#install_templatesObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/generators/kea/model/model_generator.rb', line 8

def install_templates
  @klass = name.camelize.safe_constantize
  
  if @klass
    @model_attributes       = reflected_model_attributes
    @model_associations     = reflected_model_associations
    @attribute_initializers = attribute_initializers
    
    if options[:validatable]
      @validators = @klass.validators.select {|v| v.is_a?(ActiveRecord::Validations::PresenceValidator) }
    end
  end
  
  template "model.js.erb", namespaced_path("app/assets/javascripts", "models/#{name.underscore}.js")
end