Modifying JAVASCRIPT_DEFAULT_SOURCES

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.

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

Good luck,

-Conrad

On Jan 18, 2008 7:14 PM, Chris S. removed_email_address@domain.invalid

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

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.

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

On Jan 19, 2008 12:27 PM, Chris S. 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/.


Mark Van H., Partner / Software Developer
removed_email_address@domain.invalid, (616) 706-6842
Mutually Human Software, http://mutuallyhuman.com

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 methodset_javascript_defaults’ for
ActionView::Helpers::AssetTagHelper:Module (NoMethodError)”