Class: Rails::Generators::BasepackResourceRouteGenerator
- Inherits:
-
ResourceRouteGenerator
- Object
- ResourceRouteGenerator
- Rails::Generators::BasepackResourceRouteGenerator
- Defined in:
- lib/generators/rails/basepack_resource_route_generator.rb
Instance Method Summary collapse
Instance Method Details
#add_resource_route ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/rails/basepack_resource_route_generator.rb', line 8 def add_resource_route return if [:actions].present? # iterates over all namespaces and opens up blocks regular_class_path.each_with_index do |namespace, index| write("namespace :#{namespace} do", index + 1) end # inserts the primary resource write("resources :#{file_name.pluralize}, concerns: :resourcable", route_length + 1) # ends blocks regular_class_path.each_index do |index| write("end", route_length - index) end # route prepends two spaces onto the front of the string that is passed, this corrects that route_after route_string[2..-1] end |