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

uninitialized constant Sass::Rails::SassTemplate in production #447

Closed
szymon-przybyl opened this issue Sep 1, 2011 · 11 comments
Closed
Milestone

Comments

@szymon-przybyl
Copy link
Contributor

that error points to:
gems/ruby-1.9.2-p290@farmera/bundler/gems/active_admin-d6293514b99d/lib/active_admin/sass/helpers.rb:3:in `'

helpers.rb:3 :
require 'sass-rails' if ActiveAdmin::DependencyChecker.rails_3_1?

any ideas how to fix it?

@taybenlor
Copy link

I have this issue as well. The error ends up pointing to https://github.com/rails/sass-rails/blob/3-1-stable/lib/sass/rails/railtie.rb line 38. Considering those classes do actually exist I'm assuming there's some loading-order issue going on?

@szymon-przybyl
Copy link
Contributor Author

I've created the same issue in sass-rails: #447

@taybenlor
Copy link

Does this have a relation to #437 ?

@szymon-przybyl
Copy link
Contributor Author

ok, i'm switching back to Rails 3.0.10

@watson
Copy link
Contributor

watson commented Sep 6, 2011

I got this error en development and test. It turned out to be because I've upgraded from Rails 3.1.0.rc5 to Rails 3.1.0 without updating the core files:

If you upgraded Rails to version 3.1.0 (maybe from a 3.1 release candidate) and it worked before the upgrade then you might just need to update the files generated by the rails new command. Specifically config/application.rb where the top part of the file should say:

require File.expand_path('../boot', __FILE__)

require 'rails/all'

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require *Rails.groups(:assets => %w(development test))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)
end

The important part is the if defined?(Bundler) block which makes sure that the sass-rails gem is required.

@szymon-przybyl
Copy link
Contributor Author

i have exactly that code in my config/application.rb, but it throws that error, but only in production, in development and test it works ok. probably it crashes becouse it wants to compile assets or something like that.

@szymon-przybyl
Copy link
Contributor Author

tracedwax found solution - move sass-rails out of assets group, so that sass-rails will be loaded in active_admin: rails/sass-rails#38 (comment)

@pcastellazzi
Copy link

I tracked the problem to lib/active_admin/appliaction.rb:80, generate_stylesheets should not be called on production. The solution is a two step process, first change the line to generate_stylesheets unless Rails.env.production? and then you need to add active_admin.css and active_admin.js to the list of precompiled manifests with config.assets.precompile += %w/active_admin.css active_admin.js. On my tests i did this on RAILS_ROOT/config/application.rb, but this should be done from the engine.

@chriseppstein
Copy link

It's a bad idea to rely on the environment, instead you should rely on the configuration that the environment establishes. In this case, config.assets.enabled.

@pcastellazzi
Copy link

I am not sure if that's entirely correct either. config.assets.enabled is set to true for all environments. It signal the activation of the asset pipeline only. To test if the application should relly on precompiled assets or not and to avoid the environment test, a check for config.assets.compile should be done too.

@chriseppstein
Copy link

Agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants