Sha256: 6d98a1401b1c04ce9582a7eca613e9d28a560135b52670a3b0f7e011f354fb37

Contents?: true

Size: 1.38 KB

Versions: 8

Compression:

Stored size: 1.38 KB

Contents

require_relative 'base_generator'
module Fae
  class NestedIndexScaffoldGenerator < Fae::BaseGenerator
    source_root File.expand_path('../templates', __FILE__)

    def go
      generate_model
      generate_nested_index_controller_file
      inject_display_field_to_model
      generate_view_files
      add_route
      inject_nav_item
    end


    private

      def generate_nested_index_controller_file
        template "controllers/nested_index_scaffold_controller.rb", "app/controllers/#{options.namespace}/#{file_name.pluralize}_controller.rb"
      end

      def generate_view_files
        @toggle_attrs = set_toggle_attrs
        @form_attrs = set_form_attrs
        @association_names = @@association_names
        @has_position = @@has_position
        @display_field = @@display_field
        template "views/index_nested.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/index.html.#{options.template}"
        template "views/_form_index_nested.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/_form.html.#{options.template}"
        template "views/new_nested.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/new.html.#{options.template}"
        template "views/edit_nested.html.#{options.template}", "app/views/#{options.namespace}/#{plural_file_name}/edit.html.#{options.template}"
      end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fae-rails-1.4.1 lib/generators/fae/nested_index_scaffold_generator.rb
fae-rails-1.4.0 lib/generators/fae/nested_index_scaffold_generator.rb
fae-rails-1.3.1 lib/generators/fae/nested_index_scaffold_generator.rb
fae-rails-1.3.0 lib/generators/fae/nested_index_scaffold_generator.rb
fae-rails-1.2.5 lib/generators/fae/nested_index_scaffold_generator.rb
fae-rails-1.2.4 lib/generators/fae/nested_index_scaffold_generator.rb
fae-rails-1.2.3 lib/generators/fae/nested_index_scaffold_generator.rb
fae-rails-1.2.2 lib/generators/fae/nested_index_scaffold_generator.rb