# Modifying JAVASCRIPT\_DEFAULT\_SOURCES

**URL:** <https://www.ruby-forum.com/t/modifying-javascript-default-sources/126532>\
**Category:** Rails\
**Created:** [January 19, 2008, 4:14am UTC](https://www.ruby-forum.com/t/modifying-javascript-default-sources/126532 "2008-01-19T04:14:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [January 19, 2008, 4:14am UTC](https://www.ruby-forum.com/t/modifying-javascript-default-sources/126532/1 "2008-01-19T04:14:39Z")

</div>

Anyone know an elegant way to customize the default javascript includes  
for rails?

I don’t use prototype at all – I use Ext. I wanna’ make my Ext libs +  
custom application libs the default.

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [January 19, 2008, 4:27am UTC](https://www.ruby-forum.com/t/modifying-javascript-default-sources/126532/2 "2008-01-19T04:27:08Z")

</div>

Hi, you can define the following in your environment.rb  
JAVASCRIPT\_DEFAULT\_SOURCES = [ ‘prototype’, ‘my\_js\_file1’,  
‘my\_js\_file2’,  
… ]

For further information, you can check the following site:

[http://caboo.se/doc/classes/ActionView/Helpers/AssetTagHelper.html](http://caboo.se/doc/classes/ActionView/Helpers/AssetTagHelper.html)

Good luck,

-Conrad

On Jan 18, 2008 7:14 PM, Chris S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [January 19, 2008, 7:41am UTC](https://www.ruby-forum.com/t/modifying-javascript-default-sources/126532/3 "2008-01-19T07:41:57Z")

</div>

cheers, mate. that’s what I was looking for.

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [January 19, 2008, 6:27pm UTC](https://www.ruby-forum.com/t/modifying-javascript-default-sources/126532/4 "2008-01-19T18:27:49Z")

</div>

actually, that doesn’t work.

# environment.rb

JAVASCRIPT\_DEFAULT\_SOURCES = [‘foo’, ‘bar’]

# nor does this

ActionView::Helpers::AssetTagHelper.const\_set(:JAVASCRIPT\_DEFAULT\_SOURCES,  
[‘foo’, ‘bar’])

damn. I can’t believe it’s this difficult to change the default js  
includes.

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [January 19, 2008, 6:38pm UTC](https://www.ruby-forum.com/t/modifying-javascript-default-sources/126532/5 "2008-01-19T18:38:00Z")

</div>

I created a ticket a while back to allow you to easily add to :defaults,  
or  
create your own symbols that expand to multiple sources. If this looks  
like  
something that would be useful to you, check it out and add a +1 to the  
ticket.  
[http://dev.rubyonrails.org/ticket/10350](http://dev.rubyonrails.org/ticket/10350)

On Jan 19, 2008 12:27 PM, Chris S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> damn. I can’t believe it’s this difficult to change the default js  
> includes.
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Mark Van H., Partner / Software Developer  
removed\_email\_address@domain.invalid, (616) 706-6842  
Mutually Human Software, [http://mutuallyhuman.com](http://mutuallyhuman.com)

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [January 19, 2008, 6:51pm UTC](https://www.ruby-forum.com/t/modifying-javascript-default-sources/126532/6 "2008-01-19T18:51:49Z")

</div>

> something that would be useful to you, check it out and add a +1 to the  
> ticket.

done. as a quickie, I defined my own method for  
ActionView::Helpers::AssetTagHelper #set\_javascript\_defaults

# environment.rb

ActionView::Helpers::AssetTagHelper.set\_javascript\_defaults([‘foo’,  
‘bar’])

however, now I want different resources based upon RAILS\_ENV (ie: for  
production, I want to include minified resources. I use a custom js  
builder to build my resources).

I expected I could simply place the above line into development.rb but I  
get an error:

“config/environments/development.rb:24:in `load_environment': undefined method`set\_javascript\_defaults’ for  
ActionView::Helpers::AssetTagHelper:Module (NoMethodError)”
