Sha256: 5c064ff3afc5a6ff418cdc5397b39b631b95742b79a3237c517f36b6e12c285e

Contents?: true

Size: 681 Bytes

Versions: 7

Compression:

Stored size: 681 Bytes

Contents

class Rails::ModalCrudRouteGenerator < Rails::Generators::NamedBase
  include Rails::Generators::ResourceHelpers
  source_root File.expand_path('../templates', __FILE__)

  def add_resource_route
    if Rails.application.assets.find_asset('models.js').blank?
      copy_file "models.js", "app/assets/javascripts/models.js"
    end
    inject_into_file 'app/assets/javascripts/models.js', after: "//!!! Generator adds after this line, do not delete it !!!\n" do
      "BBCrud.Models.add('#{name}', '/#{controller_name.underscore}/', '#{name.underscore}');\n"
    end
    run_resource_route
  end

  protected

  def run_resource_route
    generate 'resource_route', name
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bootbox_crud-0.1.1.6 lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb
bootbox_crud-0.1.1.5 lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb
bootbox_crud-0.1.1.4 lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb
bootbox_crud-0.1.1.3 lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb
bootbox_crud-0.1.1.2 lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb
bootbox_crud-0.1.1.1 lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb
bootbox_crud-0.1.1 lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb