javascript - Rails asset pipeline only returns error 404 -


sorry question, i'm ruby , rails novice. how asset pipeline working on rails?

in development enviroment have individual files of javascript , loaded in site/app/views/stats/index.html.erb:

<%= javascript_include_tag "/assets/jquery.js" %> <%= javascript_include_tag "/assets/stats/donut.js" %> <%= javascript_include_tag "/assets/stats/vbars.js" %> <%= javascript_include_tag "/assets/stats/progress.js" %> <%= javascript_include_tag "/assets/stats/gauge.js" %> <%= javascript_include_tag "/assets/stats/hbars.js" %> <%= javascript_include_tag "/assets/stats/widget_grid.js" %> <%= javascript_include_tag "/assets/stats/widget.js" %> 

in production enviroment not working. i'm trying developer enviroment use asset pipeline. here's got far:

in site/config/enviroment/development.rb configured

config.assets.debug = false config.assets.compile = false config.assets.digest = true 

then stopped rails server , ran

bundle exec rake assets:precompile 

and restarted rails server.

then in site/app/views/stats/index.html.erb replaced javascript includes for

<%= javascript_include_tag "stats" %> 

and created site/app/assets/javascripts/stats.js file contains

//= require stats/donut //= require stats/vbars //= require stats/progress //= require stats/gauge //= require stats/hbars //= require stats/widget_grid //= require stats/widget 

what doing wrong? appreciated.


update: problem happening because forgot include third-party library inside stats.js. had include in site/app/views/stats/index.html.erb

<%= javascript_include_tag "/assets/third-party/d3.min.js" %> 

just had remove include , add 1 stats.js

//= require third-party/d3.min.js 

thanks helped!

you have tell rails precompile file. default works application.js if create new manifest file, have include it. in config/initializers/assets.rb or production.rb add:

rails.application.config.assets.precompile << ['stats.js']

hope helps.

this post pretty helpful understand how asset pipeline works: http://www.reinteractive.net/posts/116-12-tips-for-the-rails-asset-pipeline


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -