-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Solidus install generator routing fix
A second run of the generator mounts Spree::Core::Engine a second time.
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'generators/spree/install/install_generator' | ||
|
||
Spree::InstallGenerator.class_eval do | ||
CORE_MOUNT_ROUTE = "mount Spree::Core::Engine" | ||
|
||
def install_routes | ||
routes_file_path = File.join('config', 'routes.rb') | ||
unless File.read(routes_file_path).include? CORE_MOUNT_ROUTE | ||
insert_into_file routes_file_path, after: "Rails.application.routes.draw do\n" do | ||
<<-ROUTES | ||
# This line mounts Solidus's routes at the root of your application. | ||
# This means, any requests to URLs such as /products, will go to Spree::ProductsController. | ||
# If you would like to change where this engine is mounted, simply change the :at option to something different. | ||
# | ||
# We ask that you don't use the :as option here, as Solidus relies on it being the default of "spree" | ||
#{CORE_MOUNT_ROUTE}, at: '/' | ||
ROUTES | ||
end | ||
end | ||
|
||
unless options[:quiet] | ||
puts "*" * 50 | ||
puts "We added the following line to your application's config/routes.rb file:" | ||
puts " " | ||
puts " #{CORE_MOUNT_ROUTE}, at: '/'" | ||
end | ||
end | ||
end |