Nicklas A.
Nicklas A.

Reputation: 7061

Heroku always runs assets:precompile with the production environment for Rails 3.2

I have my Heroku environment set to staging but my assets are always compiled in the production environment.

Here's heroku config:

GEM_PATH            => vendor/bundle/ruby/1.9.1
LANG                => en_US.UTF-8
PATH                => bin:vendor/bundle/ruby/1.9.1/bin:/usr/local/bin:/usr/bin:/bin
RACK_ENV            => staging

I've added an exception to the production.rb file so I know which env it's running when compiling the assets. The server starts up just fine running heroku run console shows that I'm running staging.

It's just when running assets:precompile that it's always in production.

I'd be happy to post any other config file if required.

I can add that I'm running Rails 3.2.2 and the Cedar stack on heroku


Output from heroku run rake about:

About your application's environment
Ruby version             1.9.2 (x86_64-linux)
RubyGems version         1.3.7
Rack version             1.4
Rails version            3.2.2
JavaScript Runtime       therubyracer (V8)
Action Pack version      3.2.2
Active Support version   3.2.2
Middleware               Rack::Cache, ActionDispatch::Static, Rack::Lock, #, Rack::Runtime, Rack::Auth::Basic, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Callbacks, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport
Application root         /app
Environment              staging

And running heroku run rake assets:precompile gives:

/usr/local/bin/ruby /app/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=staging RAILS_GROUPS=assets

Should I just give up and email Heroku?

Upvotes: 11

Views: 4399

Answers (2)

Nicklas A.
Nicklas A.

Reputation: 7061

Apparently I needed to enable a plugin to make it work.

Upvotes: 19

Veraticus
Veraticus

Reputation: 16064

Try setting RAILS_ENV to staging as well and see if that makes Heroku any happier.

Upvotes: 1

Related Questions