Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails assets path

I have in

  <link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css" /> 
  <script src="/assets/application.js" type="text/javascript"></script> 

but when I go to http://localhost:3000/assets/application.css

Routing Error

No route matches [GET] "/assets/application.css"

P.S. Rails 3.1.0.rc4, ruby 1.8.7

like image 541
Vyacheslav Loginov Avatar asked Aug 20 '26 19:08

Vyacheslav Loginov


2 Answers

Seems Sprockets / Rails 3.1 were acting up for me w/ ruby 1.9.2-p180 ... updating to Ruby-1.9.2-p290 seemed to stop the issue.

Maybe not related to your issue... but useful for anyone else having that issue using those versions of Rails & Ruby.

like image 94
fighella Avatar answered Aug 24 '26 00:08

fighella


I found that I had something similar going on after updating to Rails 3.1 this evening. I was working on a project that didn't use ActiveRecord, so I had a modified my application.rb to exclude it. The line that usually reads require 'rails/all' to only include the parts I needed, like this:

require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"

This list has changed in Rails 3.1 to include Sprockets, the core component to making the asset pipeline work. I got the asset pipeline serving the serving content as expected by adding this line to the bottom of the list:

require "sprockets/railtie"

After restarting, /assets/application.js and other assets began working as expected.

Note: if you have a custom setup like this, be sure to open the railties gem and look at the contents of lib/rails/all.rb which may have changed (as in this case).

like image 24
Kyle VanderBeek Avatar answered Aug 24 '26 01:08

Kyle VanderBeek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!