Actually only load rails admin in production mode

This is what I think 28f8db51e7 was supposed to do.

With the initializer in an "unless Rails.env.production?" block
the entire initializer was being ignored in production mode and
loaded in all other environments, but Rails Admin was still
loading regardless of that. 😁

This only loads rails admin in production and excludes it from
all other environments. Also keeps non-admins out of /admin_panel
(without the initializer it was free-for-all) and temp fixes #3210
until a new gem is released.
This commit is contained in:
Steven Hancock 2012-05-09 11:27:58 -07:00
parent 1207ded0ea
commit 4c644c336b
3 changed files with 5 additions and 3 deletions

View file

@ -25,7 +25,6 @@ gem 'omniauth-tumblr'
gem 'omniauth-twitter'
gem 'twitter', '2.0.2'
gem 'rails_admin'
# mail
@ -36,6 +35,7 @@ gem 'newrelic_rpm'
gem "rpm_contrib", "~> 2.1.7"
group :production do # we don't install these on travis to speed up test runs
gem 'rails_admin'
gem 'rack-ssl', :require => 'rack/ssl'
gem 'rack-rewrite', '~> 1.2.1', :require => false
gem 'rack-piwik', :require => 'rack/piwik'

View file

@ -1,6 +1,6 @@
# RailsAdmin config file. Generated on March 24, 2012 15:34
# See github.com/sferik/rails_admin for more informations
unless Rails.env.production?
if Rails.env.production?
RailsAdmin.config do |config|
config.authorize_with do
redirect_to main_app.root_path unless current_user.try(:admin?)

View file

@ -3,7 +3,9 @@
# the COPYRIGHT file.
Diaspora::Application.routes.draw do
mount RailsAdmin::Engine => '/admin_panel', :as => 'rails_admin'
if Rails.env.production?
mount RailsAdmin::Engine => '/admin_panel', :as => 'rails_admin'
end
get 'oembed' => 'posts#oembed', :as => 'oembed'
# Posting and Reading