Forum: Ruby on Rails RJS templates outputting bloated code?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9ea58bbfd3a0b9022cca4e7dedbb84e8?d=identicon&s=25 Yariv Sadan (Guest)
on 2006-04-01 00:46
I'm an RJS newbie. I just did the tutorial at
http://www.codyfauser.com/articles/2005/11/20/rail..., and
then used wget to look at the output the RJS template generates. This is
what I got:

try {
new Insertion.Bottom("list", "<li>Fox</li>");
new Effect.Highlight("list",{duration:1});
Element.update("header", "RJS Template Test Complete");
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('new
Insertion.Bottom(\"list\", \"<li>Fox</li>\");\nnew
Effect.Highlight(\"list\",{duration:1})
;\nElement.update(\"header\", \"RJS Template Test Complete\");'); throw
e }


It looks to me like the exception handling logic sent in the response
causes too much bloat. I think it's better to send only the "meat":

new Insertion.Bottom("list", "<li>Fox</li>");
new Effect.Highlight("list",{duration:1});
Element.update("header", "RJS Template Test Complete");

Thoughts?
7ed3175d60e44aa7cb891973223e3998?d=identicon&s=25 Chad Fowler (Guest)
on 2006-04-01 01:00
(Received via mailing list)
On 3/31/06, Yariv Sadan <yariv@pando.com> wrote:
> Insertion.Bottom(\"list\", \"<li>Fox</li>\");\nnew
> Element.update("header", "RJS Template Test Complete");
>
> Thoughts?
>

Hi.  This behavior only exists (by default) in development.  Look at
your config/environments/development.rb file and you should see a
setting for RJS debug.  This will help you during development but it
shouldn't show up on production.

--
Chad Fowler
http://chadfowler.com
http://pragmaticprogrammer.com/titles/fr_rr/ (Rails Recipes - In Beta!)
http://pragmaticprogrammer.com/titles/mjwti/ (My Job Went to India,
and All I Got Was This Lousy Book)
http://rubycentral.org
http://rubygarden.org
http://rubygems.rubyforge.org (over one million gems served!)
9ea58bbfd3a0b9022cca4e7dedbb84e8?d=identicon&s=25 Yariv Sadan (Guest)
on 2006-04-01 01:07
> Hi.  This behavior only exists (by default) in development.  Look at
> your config/environments/development.rb file and you should see a
> setting for RJS debug.  This will help you during development but it
> shouldn't show up on production.

Excellent! I knew you guys have probably thought of this :) Keep up the
great work!

Yariv
7ed3175d60e44aa7cb891973223e3998?d=identicon&s=25 Chad Fowler (Guest)
on 2006-04-01 02:37
(Received via mailing list)
On 3/31/06, Yariv Sadan <yariv@pando.com> wrote:
> > Hi.  This behavior only exists (by default) in development.  Look at
> > your config/environments/development.rb file and you should see a
> > setting for RJS debug.  This will help you during development but it
> > shouldn't show up on production.
>
> Excellent! I knew you guys have probably thought of this :) Keep up the
> great work!

Well, I can't personally claim to have thought of anything other than
asking Sam Stephenson recently about the best ways to debug RJS, which
is when he told me about this feature :)

--
Chad Fowler
http://chadfowler.com
http://pragmaticprogrammer.com/titles/fr_rr/ (Rails Recipes - In Beta!)
http://pragmaticprogrammer.com/titles/mjwti/ (My Job Went to India,
and All I Got Was This Lousy Book)
http://rubycentral.org
http://rubygarden.org
http://rubygems.rubyforge.org (over one million gems served!)
This topic is locked and can not be replied to.