Search code examples
javascriptruby-on-rails-4stylesheetassets

Rails 4 - Stylesheets from public folder


I have a problem with including stylesheets and javascript files from public folder into my project.

I do it in following way:

<%= stylesheet_link_tag '/public/dist/css/AdminLTE.min.css' %> 

Unfortunatelly I've got an error:

ActionController::RoutingError (No route matches [GET] "/public/dist/css/AdminLTE.min.css")

Can u tell me how to solve this?


Solution

  • Remove the '/public/' path.

    <%= stylesheet_link_tag '/dist/css/AdminLTE.min.css' %> 
    

    Files under public don't need the /public/ path. An example are your error pages that can be reached by localhost:3000/404.html

    Enabling this in production requires you to enable it in your environment file.

    In production.rb

    config.serve_static_assets = true