Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Heroku returning 'devise/sessions.js isn't precompiled'?

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!

like image 824
Andy Harvey Avatar asked Apr 10 '12 15:04

Andy Harvey


3 Answers

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.

like image 124
Andy Harvey Avatar answered Oct 12 '22 11:10

Andy Harvey


My solution:

<%= javascript_include_tag "application", controller_name if controller_name != "sessions" %>
like image 42
We Going Nowhere Avatar answered Oct 12 '22 12:10

We Going Nowhere


Try running rake assets:precompile.


Try adding this to your config/environments/production.rb :

config.assets.precompile += %w( *.css *.js )

Or specify your file.

like image 26
Justin D. Avatar answered Oct 12 '22 13:10

Justin D.