Class: Webring::Generators::NavigationControllerGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Webring::Generators::NavigationControllerGenerator
- Includes:
- Shared::RouteInjector
- Defined in:
- lib/generators/webring/navigation_controller/navigation_controller_generator.rb
Overview
Note:
This generator should be run after installing the Webring engine and generating the Member model with webring:member
This generator creates both the controller file and adds the required routes
Instance Method Summary collapse
-
#create_controller_file ⇒ Object
Creates the NavigationController file based on the template.
-
#create_navigation_routes ⇒ Object
Adds navigation routes to the application’s routes.rb file These routes are used to navigate between webring members.
Instance Method Details
#create_controller_file ⇒ Object
Creates the NavigationController file based on the template
25 26 27 |
# File 'lib/generators/webring/navigation_controller/navigation_controller_generator.rb', line 25 def create_controller_file template 'navigation_controller.rb', 'app/controllers/webring/navigation_controller.rb' end |
#create_navigation_routes ⇒ Object
Adds navigation routes to the application’s routes.rb file These routes are used to navigate between webring members
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/generators/webring/navigation_controller/navigation_controller_generator.rb', line 31 def route_content = <<~ROUTE # Webring navigation routes namespace :webring do root to: 'navigation#random' get 'next', to: 'navigation#next' get 'previous', to: 'navigation#previous' get 'random', to: 'navigation#random' end ROUTE inject_webring_routes(route_content) end |