# Asset packager for Rails 2

**URL:** <https://www.ruby-forum.com/t/asset-packager-for-rails-2/121827>\
**Category:** Rails\
**Created:** [December 1, 2007, 2:06pm UTC](https://www.ruby-forum.com/t/asset-packager-for-rails-2/121827 "2007-12-01T14:06:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![helzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19b73/32.png) [@helzer](https://www.ruby-forum.com/u/helzer)\
**Post date:** [December 1, 2007, 2:06pm UTC](https://www.ruby-forum.com/t/asset-packager-for-rails-2/121827/1 "2007-12-01T14:06:46Z")

</div>

I’ve tried to fix asset\_packager ([Pages | Synthesis | Scott Becker](http://synthesis.sbecker.net/pages/)  
asset\_packager) for Rails 2, but while doing this, it seems like I’m  
patching something that’s already built-in.

Is asset\_packager actually built into Rails 2?

If so, how do I use it?

Thanks,  
Helzer

---

<div class="post-metadata">

**Author:** ![helzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19b73/32.png) [@helzer](https://www.ruby-forum.com/u/helzer)\
**Post date:** [December 1, 2007, 2:12pm UTC](https://www.ruby-forum.com/t/asset-packager-for-rails-2/121827/2 "2007-12-01T14:12:02Z")

</div>

It’s automagically used in production mode.

---

<div class="post-metadata">

**Author:** ![helzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19b73/32.png) [@helzer](https://www.ruby-forum.com/u/helzer)\
**Post date:** [December 1, 2007, 2:18pm UTC](https://www.ruby-forum.com/t/asset-packager-for-rails-2/121827/3 "2007-12-01T14:18:28Z")

</div>

But, how do I use it?

Right now (Rails 1.2.6), I have the config/asset\_packages.yml list of  
packages and these two to instantiate the assets:  
\<%= stylesheet\_link\_merged :base %\>  
\<%= javascript\_include\_merged :base %\>

What do I need to do with the built in Rails 2 asset packager?

Doing the same, but just deleting the plugin/asset\_packager didn’t  
help.

---

<div class="post-metadata">

**Author:** ![helzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19b73/32.png) [@helzer](https://www.ruby-forum.com/u/helzer)\
**Post date:** [December 2, 2007, 5:43pm UTC](https://www.ruby-forum.com/t/asset-packager-for-rails-2/121827/4 "2007-12-02T17:43:30Z")

</div>

Just specify:

```
<%= javascript_include_tag :defaults, 'reflection.js',

```

‘…’, :cache =\> true %\>

---

<div class="post-metadata">

**Author:** ![helzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19b73/32.png) [@helzer](https://www.ruby-forum.com/u/helzer)\
**Post date:** [December 3, 2007, 1:42am UTC](https://www.ruby-forum.com/t/asset-packager-for-rails-2/121827/5 "2007-12-03T01:42:59Z")

</div>

> ```
> <%= javascript_include_tag :defaults, 'reflection.js',
> 
> ```
> 
> ‘…’, :cache =\> true %\>

1. Using asset\_packager, I had a rake task which created a single  
Javascript and single CSS file from the multiple JS, CSS files I use.  
It also compressed them. I ran this task when deploying.  
Do I need to do anything similar with the current scheme?

2. I have another environment, which I called ‘sandbox’. This  
environment behaves exactly like the production environment (just with  
a different database). How should I tell Rails 2 to apply asset  
caching to this environment too?

Thanks,  
Helzer

---

<div class="post-metadata">

**Author:** ![helzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e19b73/32.png) [@helzer](https://www.ruby-forum.com/u/helzer)\
**Post date:** [December 3, 2007, 9:28am UTC](https://www.ruby-forum.com/t/asset-packager-for-rails-2/121827/6 "2007-12-03T09:28:57Z")

</div>

When :cache is true and ActionController::Base.perform\_caching is  
true, all the javascript files are combined into one all.js (same with  
css files). However, the files are not compressed nor minified.
