Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize routes per Rails::Engine Initializer #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,7 @@ Add an initializer to your Rails project in which you tell Smurfville where it c
if defined?(Smurfville)
Smurfville.sass_directory = Rails.root.join('app', 'assets', 'stylesheets').to_s
end

Mount the `Smurfville::Engine` in your routes:

# config/routes.rb

if defined?(Smurfville)
mount Smurfville::Engine => "/smurfville"
end

Restart your server and you should be able to access the SMURF pages, e.g. `yourapp.com/smurfville/colors`

## Screenshot
Expand Down
6 changes: 6 additions & 0 deletions lib/smurfville/engine.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module Smurfville
class Engine < ::Rails::Engine
isolate_namespace Smurfville

initializer "smurfville.routes" do |app|
app.routes.prepend do
mount Smurfville::Engine => "/smurfville"
end
end
end
end
2 changes: 0 additions & 2 deletions test/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
Rails.application.routes.draw do

mount Smurfville::Engine => "/smurfville"
end