Class: AppKit::ResourceGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/app_kit/resource/resource_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_resource_fileObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/app_kit/resource/resource_generator.rb', line 4

def create_resource_file
  begin
    @resource_class = Object.const_get(class_name)
    template "resource.rb", "app/app_kit/#{file_name}.rb"
  rescue NameError
    puts ""
    puts "The #{class_name} model doesn't exist."
    puts "AppKit resources are bound to models. You must first generate a model for the resource."
    puts ""
    puts "You can generate a model for this resource by running:"
    puts "rails g model #{class_name.underscore} column:string, column2:integer"
    return
  end

end