Commit 1590b7c01f01efbef50639e1248ae67d5bb30474
1 parent
1782ed45
Exists in
staging
and in
42 other branches
Auto-create environment in development mode
Sometimes I am fiddling with databases, destroying and recreating them, and I forget to recreate some data and the app explodes in my face because Environment.default returns nil.
Showing
1 changed file
with
4 additions
and
0 deletions
Show diff stats
app/controllers/application_controller.rb
| ... | ... | @@ -91,6 +91,10 @@ class ApplicationController < ActionController::Base |
| 91 | 91 | @domain = Domain.find_by_name(request.host) |
| 92 | 92 | if @domain.nil? |
| 93 | 93 | @environment = Environment.default |
| 94 | + if @environment.nil? && Rails.env.development? | |
| 95 | + # This should only happen in development ... | |
| 96 | + @environment = Environment.create!(:name => "Noosfero", :is_default => true) | |
| 97 | + end | |
| 94 | 98 | else |
| 95 | 99 | @environment = @domain.environment |
| 96 | 100 | @profile = @domain.profile | ... | ... |