I'm deploying a Rails 3.2 app to Heroku. I'm precompiling assets locally as per https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar.
我正在向Heroku部署Rails 3.2应用程序。我根据https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar在本地预编译资产。
But I'm getting
但我得到了
ActionView::Template::Error (devise/sessions.js isn't precompiled):
Has anyone else encountered this?
有人遇到过这种情况么?
What is the correct way to ensure Devise javascripts are precomiled.
什么是确保Devise javascripts预先推出的正确方法。
Thanks!
3 个解决方案
#1
6
Thank you for all the suggestions. After a bit of thinking, I realize that the issue was down to how the app was configured to call controller-specific javascript. IN case anyone else runs into this issue, here's what I did.
谢谢你提出的所有建议。经过一番思考后,我意识到问题在于应用程序如何配置为调用控制器特定的javascript。如果有其他人遇到这个问题,这就是我做的。
I had been loading controller-specific .js via the following tag in the layout file.
我一直在布局文件中通过以下标记加载特定于控制器的.js。
<%= javascript_include_tag "application", params[:controller] %>
Problem is, this fails if a particular cotroller.js file does not exist. In my case, the login page failed as I had not created a devise/sessions.js file.
问题是,如果特定的cotroller.js文件不存在,则会失败。在我的情况下,登录页面失败,因为我没有创建devise / sessions.js文件。
I could have created this file, but I felt this was a messy approach. I don't like the idea of having a lot of empty files lying around.
我本可以创建这个文件,但我觉得这是一个混乱的方法。我不喜欢有很多空文件的想法。
Instead I am explicitly calling controller-specific javascripts from the view
相反,我明确地从视图中调用特定于控制器的javascripts
<% javascript 'controller.js' %>
Using the following helper in application_helpers
在application_helpers中使用以下帮助程序
def javascript(*files)
content_for(:head) { javascript_include_tag(*files) }
end
Seems to be working fine so far.
到目前为止似乎工作正常。
Thanks again for the suggestions.
再次感谢您的建议。
#2
5
My solution:
<%= javascript_include_tag "application", controller_name if controller_name != "sessions" %>
#3
3
Try running rake assets:precompile
.
尝试运行rake资产:预编译。
Try adding this to your config/environments/production.rb :
尝试将此添加到config / environments / production.rb:
config.assets.precompile += %w( *.css *.js )
Or specify your file.
或者指定您的文件。
#1
6
Thank you for all the suggestions. After a bit of thinking, I realize that the issue was down to how the app was configured to call controller-specific javascript. IN case anyone else runs into this issue, here's what I did.
谢谢你提出的所有建议。经过一番思考后,我意识到问题在于应用程序如何配置为调用控制器特定的javascript。如果有其他人遇到这个问题,这就是我做的。
I had been loading controller-specific .js via the following tag in the layout file.
我一直在布局文件中通过以下标记加载特定于控制器的.js。
<%= javascript_include_tag "application", params[:controller] %>
Problem is, this fails if a particular cotroller.js file does not exist. In my case, the login page failed as I had not created a devise/sessions.js file.
问题是,如果特定的cotroller.js文件不存在,则会失败。在我的情况下,登录页面失败,因为我没有创建devise / sessions.js文件。
I could have created this file, but I felt this was a messy approach. I don't like the idea of having a lot of empty files lying around.
我本可以创建这个文件,但我觉得这是一个混乱的方法。我不喜欢有很多空文件的想法。
Instead I am explicitly calling controller-specific javascripts from the view
相反,我明确地从视图中调用特定于控制器的javascripts
<% javascript 'controller.js' %>
Using the following helper in application_helpers
在application_helpers中使用以下帮助程序
def javascript(*files)
content_for(:head) { javascript_include_tag(*files) }
end
Seems to be working fine so far.
到目前为止似乎工作正常。
Thanks again for the suggestions.
再次感谢您的建议。
#2
5
My solution:
<%= javascript_include_tag "application", controller_name if controller_name != "sessions" %>
#3
3
Try running rake assets:precompile
.
尝试运行rake资产:预编译。
Try adding this to your config/environments/production.rb :
尝试将此添加到config / environments / production.rb:
config.assets.precompile += %w( *.css *.js )
Or specify your file.
或者指定您的文件。