Fletcher Moore
Fletcher Moore

Reputation: 13814

How do I use rails assets without sprockets?

I have created a new rails app with the --skip-sprockets flag. I added a single root route to a simple hello world welcome#index as in the tutorial and I have updated the associated stylesheet. When I request the page, I get the error: ActionController::RoutingError (No route matches [GET] "/stylesheets/application.css").

I had hoped to avoid sprockets, as this is a simple website and I just wanted to drop the newest boostrap in public without headache. I assume without sprockets now my public folder isn't automatically populated at all. How can I fix this?

Upvotes: 0

Views: 474

Answers (1)

Benjamin Bouchet
Benjamin Bouchet

Reputation: 13181

Place your assets files (javascript, css, images) in the public folder, example: /public/application.css

Then in your application layout file replace stylesheet_link_tag 'application' by <link rel="stylesheet" media="all" href="/application.css">

You will have to do the same for javascript. Also you will not be able to use image_tag or asset_path helpers

Explanation: everything which is in public folder will be rendered by your web server without going through the rails application

Upvotes: 1

Related Questions