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.
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.
Thanks!
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.
I had been loading controller-specific .js via the following tag in the layout file.
<%= 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.
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
<% javascript 'controller.js' %>
Using the following helper in 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.
My solution:
<%= javascript_include_tag "application", controller_name if controller_name != "sessions" %>
Try running rake assets:precompile
.
Try adding this to your config/environments/production.rb :
config.assets.precompile += %w( *.css *.js )
Or specify your file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With