Asset Pipeline is not serving assets, but no errors. Is this config correct?

I'm new to RoR (but a seasoned developer) and love it ... but I hit a brick wall with the Asset Pipeline! I have a legacy application that I am modifying to use an asset pipeline. I read article after article on SO and other sites, but I just can't get this to work. Here are the details:

Ruby Version : 2.0.0-p353

Rails version : 3.1.12

Content of the app / assets / javascripts directory :

application.js          
bootstrap.js            
event_calendar.js       
jquery-ui-timepicker-addon.js   
jquery-ui.js            
jquery.js
jquery.prettyPhoto.js
jrails.js
mce_editor.js
rails.js
/tiny_mce

      

Content of application.js file :

//= require bootstrap
//= require event_calendar
//= require jquery
//= require jquery.prettyPhoto
//= require jquery-ui
//= require jquery-ui-timepicker-addon
//= require jrails
//= require mce_editor
//= require rails
//= require_tree ./tiny_mce

      

Content of the app / assets / stylesheets directory :

application.css         
/blueprint          
bootstrap-responsive.css    
bootstrap.css           
common.css          
contributed.css         
event_calendar.css      
jquery-custom.css
jquery-ui-timepicker-addon.css
marketing.css
prettyPhoto.css
registration.css
sysadministration.css
template.css
/ui-darkness

      

Content of application.css file :

/*
*= require bootstrap
*= require bootstrap-responsive
*= require common
*= require contributed
*= require event_calendar
*= require jquery-custom
*= require jquery-ui-timepicker-addon
*= require marketing
*= require prettyPhoto
*= require registration
*= require sysadministration
*= require template
*= require_tree ./blueprint
*= require_tree ./ui-darkness
*/

      

Config / application.rb setting :

config.assets.enabled = true

      

Helpers in the annex /views/layouts/application.html.erb

<%= stylesheet_link_tag    "application" %>
<%= javascript_include_tag "application" %>

      

Config / environment / development.rb settings :

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

      

Contents of the / public / assets folder :

(empty)

      

When I browse localhost:3000/assets/application.js

, I just return the content of the application.js file. Likewise for application.css. However, there is a noticeable ending semicolon from application.js:

//= require bootstrap
//= require event_calendar
//= require jquery
//= require jquery.prettyPhoto
//= require jquery-ui
//= require jquery-ui-timepicker-addon
//= require jrails
//= require mce_editor
//= require rails
//= require_tree ./tiny_mce
;

      

I've tried chasing that semicolon endpoint with no luck. I changed the order of the require, thinking that I could narrow down any syntax errors in the .js code, but this effort was unsuccessful.

When my pages are rendered, it doesn't have any style or js (as expected, since the resource pipeline isn't working).

I also tried using directives require_tree .

in application.css and application.js rather than explicitly listing each file, but that didn't work either.

Finally, there are no errors in my server console. It looks like Rails thinks the assets are being served correctly:

Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-08-02 15:31:02 -0400
Served asset /application.css - 304 Not Modified (0ms)

Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-08-02 15:31:02 -0400
Served asset /application.js - 304 Not Modified (0ms) 

      

Based on the information I have provided, are there any glaring omissions in my configuration? Anyone have any suggestions to get this to work?

Thank!

+3


source to share


1 answer


I decided to upgrade to Rails 3.2.18 and solved this problem (I followed RailsGuides # 318 "Upgrading to Rails 3.2"). Now my js and css are delivered to the browser:

application.js

application.css



And the server console displays assets that are provided separately (dev mode):

Started GET "/assets/bootstrap.css?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /bootstrap.css - 304 Not Modified (0ms)

Started GET "/assets/jquery-custom.css?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /jquery-custom.css - 304 Not Modified (0ms)

Started GET "/assets/contributed.css?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /contributed.css - 304 Not Modified (0ms)

[deleted for brevity]

Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /application.css - 304 Not Modified (0ms)

Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /jquery.js - 304 Not Modified (0ms)

Started GET "/assets/jquery.prettyPhoto.js?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /jquery.prettyPhoto.js - 304 Not Modified (0ms)

Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /jquery-ui.js - 304 Not Modified (0ms)

Started GET "/assets/jquery-ui-timepicker-addon.js?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /jquery-ui-timepicker-addon.js - 304 Not Modified (0ms)

Started GET "/assets/bootstrap.js?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /bootstrap.js - 304 Not Modified (0ms)

Started GET "/assets/event_calendar.js?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /event_calendar.js - 304 Not Modified (0ms)

Started GET "/assets/mce_editor.js?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /mce_editor.js - 304 Not Modified (0ms)

Started GET "/assets/jrails.js?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /jrails.js - 304 Not Modified (0ms)

Started GET "/assets/rails.js?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /rails.js - 304 Not Modified (0ms)

Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-08-04 06:07:20 -0400
Served asset /application.js - 304 Not Modified (0ms)

      

0


source







All Articles