dan
dan

Reputation: 45632

How do you get static assets in a Rails Engine to work in Rails 3.0 and Rails 3.1?

I've read previous StackOverflow answers to this question but they are all over the map. Is there a definitive answer anywhere on how you should bundle static assets (css and js files) with your Rails Engine and how you can get them to work in Rails 3.0 and 3.1?

Upvotes: 2

Views: 135

Answers (1)

Eric C
Eric C

Reputation: 2205

This question is a bit vague, but let me see if I can't give a decent answer. I'm not familiar with Rails 3.1 yet, but I understand if you want to separate your static assets you can create a gem to house your assets and just plug them in like that. Checkout

http://guides.rubyonrails.org/asset_pipeline.html

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

After that, I have more experience implementing engines in rails 3.0, which can be a bit crazy. Engines sort of work as gemified applications that can plug into other application and meshes all of its code into the main app, this includes assets, models, controllers, views, routes, etc. Which can be both a blessing and a curse. It's certainly unique in that you can create divisions between applications and be great for separating and reusing content, but it's a curse if you don't properly namespace things and cause headaches with name collisions.

I don't know exactly how you SHOULD bundle your assets, but if it were me I'd just use the the engine as the container for static assets if it pertains to just that engine. And at least in rails 3.0 you have to do it that way. Well or you could use Jammit, http://documentcloud.github.com/jammit/

Hope that's what you were looking for.

Upvotes: 1

Related Questions