当点击应用程序一段时间没有任何活动时,它会抛出以下错误:
Sass::SyntaxError (File to import not found or unreadable: active_admin/mixins.
如果我刷新页面,它完全加载,没有任何错误。
这是一个Heroku问题还是一个真正的应用程序错误?有人知道解决方法吗?
你需要从组集中删除gem 'sass-rails', " ~> 3.1.0"。
我猜你有一个Sass语法错误,资产管道在编译期间正在处理。它只在不活动后发生的原因是应用程序被Heroku闲置,需要重新启动以服务请求,因此资产管道再次"唤醒"。
添加一个sass_heroku。Rb来配置/初始化器,它应该做的技巧
heroku = !!ENV['HEROKU_TYPE']
css_dir = heroku ? 'tmp' : 'public'
location = Rails.root + 'app/styles'
unless Sass::Plugin.template_location_array.any? { |pair| pair.first.to_s == location.to_s }
Sass::Plugin.add_template_location(location, Rails.root + css_dir + 'stylesheets')
end
if heroku
Sass::Plugin.template_location_array.each do |template_location, css_location|
css_location.sub!(%r{/public/stylesheets$}, "/#{css_dir}/stylesheets")
end
Rails.configuration.middleware.insert_after 'Sass::Plugin::Rack', 'Rack::Static', :urls => ['/stylesheets'], :root => "#{Rails.root}/tmp"
end
我试了好几次都没有效果。我尝试在本地和Heroku上预编译。
当我点击我的Heroku网站时,我得到…
ActionView::Template::Error (File to import not found or unreadable: active_admin/mixins.
2012-08-01T22:00:22+00:00 app[web.2]: Load paths:
2012-08-01T22:00:22+00:00 app[web.2]: /app
2012-08-01T22:00:22+00:00 app[web.2]: /app/vendor/bundle/ruby/1.9.1/gems/activeadmin-0.4.4/app/assets/stylesheets
2012-08-01T22:00:22+00:00 app[web.2]: (in /app/app/assets/stylesheets/active_admin.css.scss)):
2012-08-01T22:00:22+00:00 app[web.2]: 6: <title><%= [@page_title, active_admin_application.site_title].compact.join(" | ") %></title>
2012-08-01T22:00:22+00:00 app[web.2]: 7:
2012-08-01T22:00:22+00:00 app[web.2]: 8: <% ActiveAdmin.application.stylesheets.each do |style| %>
2012-08-01T22:00:22+00:00 app[web.2]: 9: <%= stylesheet_link_tag style.path, style.options %>
2012-08-01T22:00:22+00:00 app[web.2]: 10: <% end %>
2012-08-01T22:00:22+00:00 app[web.2]: 11: <% ActiveAdmin.application.javascripts.each do |path| %>
2012-08-01T22:00:22+00:00 app[web.2]: 12: <%= javascript_include_tag path %>
2012-08-01T22:00:22+00:00 app[web.2]: app/assets/stylesheets/active_admin.css.scss:2
我尝试了Stephane Paul的解决方案,尽管我不够聪明,无法理解它-没有帮助。
为我解决问题的是提前预编译。
只是为了澄清,我只在尝试在Heroku上使用activeadmin时看到这个错误-在开发中工作得很好。
解决方案是运行rake assets:precompile
,并确保git提交公共/资产目录到heroku,这样就不会预编译资产本身,因此错误将被跳过。