Sha256: 5810327dd438ff64530f40091bca942209d5bffdfc53bd032e3224a304b6c724

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
require 'generators/my_scaffold_generator'

module Rails
  module Generators
    class MyControllerGenerator < ScaffoldControllerGenerator
      include MyGenerators::Generators::MyScaffoldGenerator
      class_option :belongs_to, :desc => "This controller should be nested", :default=>nil, :required=>false
      class_option :embedded_in, :desc => "This controller is embedded but not nested.", :default=>nil, :required=>false

      protected
      
        def embedded?
          options[:embedded_in]
        end
        def belongs_to?
          options[:belongs_to]
        end
        def parent_name
          options[:embedded_in] || options[:belongs_to]
        end
        def parent_class
          parent_name.camelize
        end
        def parent_id
          parent_name + "_id"
        end
        def self.source_root
          @source_root ||= File.expand_path("templates", File.dirname(__FILE__))
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
my_generators-0.0.4 lib/generators/rails/my_controller_generator.rb
my_generators-0.0.3 lib/generators/rails/my_controller_generator.rb
my_generators-0.0.2 lib/generators/rails/my_controller_generator.rb
my_generators-0.0.1 lib/generators/rails/my_controller_generator.rb