ediblecode
ediblecode

Reputation: 11971

Managing assets for different areas with Rails

Is it possible to have different assets for different areas of a site in Rails. For example, in my admin area, I'm using bootstrap but this is getting loaded in non admin areas too. I guess it's to do with my folder structure but I've tried moving it and haven't really had any luck.

Anything admin related is where you'd expect a normal controller, view or asset except it's nested within an admin folder. E.g.

App > Assets > Stylesheets > Admin

Upvotes: 0

Views: 31

Answers (1)

TrevTheDev
TrevTheDev

Reputation: 2737

You can customise the asset pipeline to whatever you require. described in detail here: http://guides.rubyonrails.org/asset_pipeline.html#manifest-files-and-directives

also here: http://railscasts.com/episodes/279-understanding-the-asset-pipeline

Note in your app/assets/javascripts/application.js this little line:

//= require_tree .

which instructs sprocket to load all files in your assets javascript folder tree. Change this this line to limit to specific files.

Upvotes: 1

Related Questions