Class: Blacklight::ControllerGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/blacklight/controller_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_blacklight_catalogObject

Generate blacklight catalog controller



26
27
28
# File 'lib/generators/blacklight/controller_generator.rb', line 26

def create_blacklight_catalog
  template "catalog_controller.rb", "app/controllers/#{controller_name}_controller.rb"
end

#inject_blacklight_controller_behaviorObject

Add Blacklight to the application controller



17
18
19
20
21
22
23
# File 'lib/generators/blacklight/controller_generator.rb', line 17

def inject_blacklight_controller_behavior
  inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
    "  # Adds a few additional behaviors into the application controller\n" \
      "  include Blacklight::Controller\n" \
      "  layout :determine_layout if respond_to? :layout\n\n"
  end
end

#inject_blacklight_routesObject



30
31
32
33
34
35
36
37
38
# File 'lib/generators/blacklight/controller_generator.rb', line 30

def inject_blacklight_routes
  route <<-EOF
  concern :searchable, Blacklight::Routes::Searchable.new

  resource :catalog, only: [:index], as: 'catalog', path: '/catalog', controller: 'catalog' do
concerns :searchable
  end
  EOF
end