Class: ArcrudGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/arcrud/arcrud_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_entity_baseObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/arcrud/arcrud_generator.rb', line 9

def copy_entity_base
  angular_app_location = 'app/assets/javascripts/app'
  #copy_file "entity/entity-ctrl.js", angular_app_location + "/#{file_name}/#{file_name}-ctrl.js"

  # Copy the entity templates to app codebase
  directory 'entity', angular_app_location + '/%file_name%'

  # Add routes to state provider
  inject_into_file angular_app_location + '/app.js', :after => "\t$stateProvider" do
    "\n\t\t\t.state('" + file_name + "', {
      url: '/" + file_name + "',
      controller: '" + file_name.capitalize + "Ctrl',
      templateUrl: 'app/" + file_name + "/" + file_name + ".html',
      resolve: {
        " + file_name.capitalize + "List: ['" + file_name.capitalize + "Service', function(" + file_name.capitalize + "Service) {
          return " + file_name.capitalize + "Service.query();
        }]
      }
    })\n"
  end

end