0

I'm actually building a new app under Rails 4. I used to put my javascript_includes_tag at the bottom of my layout. But for an unknown reason, it creates a bug when trying to use confirm: on delete link. So I put back this line at the top :

!!!
%html{ :lang => 'en' }
  %head
    = stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true
    = javascript_include_tag "application", "data-turbolinks-track" => true

So far so good, the bug is now gone. Anyway, since my app is gonna use a lot of Javascript, I still need to load those third part library at the bottom. So, what I did is to only let the Rails library at the top :

// application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks

Then I tried to create another js file named third-part and try to do the same as application but including my third part libraries. Unfortunately, it does not work.

// third-part.js
//= require bootstrap
//= require app
//= require app.plugin

How can I add another javascript_includes_tag at the bottom the same way I did for application? Here I mean that on production it will also compress those files.

Thanks a lot for your help

EDIT :
It's actually loading my files well on DEVELOPMENT, but not on my production.
On production I just got <script data-turbolinks-track="true" src="/javascripts/third-part.js"></script> and I can't access the file

I've tried :

config.assets.precompile += %w( third-part.js )

and

rake assets:precompile RAILS_ENV=production

but it still not working

EDIT 2 :
I made a test of precompliling on production mode from my local machine. It did work. It might be a problem with my server.

EDIT 3 :
Just earse my application from server and clone a new one from my Github but it's still not working. Don't know why :(

4

1 回答 1

1

在您的 config/environments/production.rb 添加此行以预编译外部资产

config.assets.precompile += ["third-part.js"]

并且不要忘记在生产环境中预编译资产时提及 env=production。

于 2013-09-18T05:18:13.800 回答