Skip to content

Commit

Permalink
Mount in dev and test by default, allow override
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Morrison committed Oct 27, 2011
1 parent 192649b commit ef4014d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ your Gemfile so

gem "jasminerice"

Now add a route to the end of your config/routes.rb but only for development and test

if ["development", "test"].include? Rails.env
mount Jasminerice::Engine => "/jasmine"
end
The engine is automatically mounted into your application in the development
and test environments. If you'd like to change that behavior, you can
override the array `Jasminerice.environments` in an initializer.

Create a single file called

Expand Down
6 changes: 6 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@

root :to => "spec#index"
end

Rails.application.routes.draw do

This comment has been minimized.

Copy link
@dnagir

dnagir Nov 5, 2011

Contributor

I think it would be better to prepend it to the routes.
It will ensure the /jasmine always takes precedence over wider, common routes such as:

match '/:action', :controller => 'pages', :as => :page

If a similar route exists, then /jasmine will never be accessible without modifying existing routes.

I think it is reasonable to assume that /jasmine is the URL for Jasmine, not for a real page.

if Jasminerice.environments.include? Rails.env

This comment has been minimized.

Copy link
@dnagir

dnagir Nov 5, 2011

Contributor

We can also avoid adding Jasminerice.environments config variable if we mount the engine this way:

mount Jasminerice::Engine => "/jasmine" if defined? Jasminerice

This makes it consistent with the Gemfile and allows you to control it from there (by adding gem to a particular group).

Seems to be much cleaner then messing with additional config variable (which in most cases should correspond to the Gemfile)

mount Jasminerice::Engine => "/jasmine"
end
end
2 changes: 2 additions & 0 deletions lib/jasminerice.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "jasminerice/engine"

module Jasminerice
mattr_accessor :environments
self.environments = %w(development test)
end

1 comment on commit ef4014d

@jasonm
Copy link
Contributor

@jasonm jasonm commented on ef4014d Nov 9, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnagir, thanks for the comments - I agree with making the Gemfile the canonical place to declare environments for Jasminerice, so +1 to your changes.

Please sign in to comment.