problem redirecting to rjs template

I'm working with two controllers- login and admin. When the login
action in the login controller has worked out successfully, it
redirects to an index.rjs template in the admin controller. The
problem is that this rjs template doesn't get interpreted, so I'm left
with a screenful of javascript.

Here's the login action:

  def login
    if request.get?
      session[:user_id] = nil
      @user = User.new
    else
      @user = User.new(params[:user])
      logged_in_user = @user.try_to_login
      if logged_in_user
        session[:user_id] = logged_in_user.id
        session[:user_name] = logged_in_user.name
        session[:user_roommate] = logged_in_user.roommate
        jumpto = session[:jumpto] || {:controller => "admin", :action
=>"index"}
        session[:jumpto] = nil
        redirect_to(jumpto)
      else
        flash[:notice] = "Invalid user/password combination"
      end
    end
  end

... and here's the index.rjs that it redirects to:

page.replace_html 'content', :partial => 'list'
page.replace_html 'nav', :partial => 'nav_this_month'

... and here's what ends up on my screen:
try {
Element.update("content", "<div id=\"payments\">\n<div
id=\"form\">\n\t<form action=\"/admin/create/23\" method=\"post\"
onsubmit=\"new Ajax.Request('/admin/create/23', {asynchronous:true,
evalScripts:true, parameters:Form.serialize(this)}); return
false;\">\n<table>\n\n<tr id=\"form_row\">\t\n\t<th
class=\"date\"><input id=\"payment_date\" name=\"payment[date]\"
order=\"monthdayyear\" size=\"9\" type=\"text\"
use_month_numbers=\"true\" value=\"11/19/2006\" /></th>\n\t<th
class=\"payee\"><input id=\"payment_payee\" maxsize=\"15\"
name=\"payment[payee]\" size=\"12\" type=\"text\" value=\"payee\"
/></th>\n \t<th class=\"note\"><input id=\"payment_note\"
maxsize=\"17\" name=\"payment[note]\" size=\"17\" type=\"text\"
value=\"note\" /></th>\n\t<th class=\"payer\"><select
id=\"payment_payer\" name=\"payment[payer]\"><option
value=\"chris\">chris</option>\n<option value=\"josh\"
selected=\"selected\">josh</option></select></th>\n\t<th
class=\"amount\"><input id=\"form_amount\" maxsize=\"8\"
name=\"payment[amount]\" size=\"7\" type=\"text\" value=\"0.00\"
/></th>\n\t<th class=\"divvy\" id=\"form_submit\"><input
name=\"commit\" type=\"submit\" value=\"divvy!\"
/></th>\n</tr>\n</form>\n</table>\n</div>\n\n<table>\n\t<tr
id=\"register_header\">\n\t\t<th class=\"date\"><a href=\"#\"
onclick=\"new Ajax.Request('/admin/previous_month', {asynchronous:true,
evalScripts:true}); return
false;\"><<</a>\n\t\t\t\t\t\tdate\n\t\t\t\t\t\t<a href=\"#\"
onclick=\"new Ajax.Request('/admin/next_month', {asynchronous:true,
evalScripts:true}); return false;\">>></a>\n\t\t\t\t\t\t</th>\n\t\t<th
class=\"payee\">payee</th><th class=\"note\">note</th><th
class=\"payer\">payer</th><th class=\"amount\"
id=\"register_header_amount\">amount</th><th class=\"divvy\"
id=\"register_header_divvy\">divvy</th><th
id=\"register_header_runningbalance\">balance</th><th><th></tr>\n\t\t<tbody
id=\"register\">\n\t\t\n\n<tr class = debit
id=\"21\">\n\n\t<td>11/16/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\"amount\">$10.00</td>\t\t\n\t<td
class=\"divvy\">$-5.00</td>\n\n\t<td
class=\"runningbalance_debit\">$-25.00</td>\n\t\t\n\t\t
\n\t\t\n\t\t<td><a href=\"#\" onclick=\"new
Ajax.Request('/admin/edit/21', {asynchronous:true, evalScripts:true});
return false;\"><img alt=\"Edit\" border=\"0\"
src=\"/images/edit.png?1142214964\" /></a></td>\n\t\t\n\t\t<td><a
href=\"#\" onclick=\"new Ajax.Updater('register', '/admin/destroy/21',
{asynchronous:true, evalScripts:true}); return false;\"><img
alt=\"Destroy\" border=\"0\" src=\"/images/destroy.png?1142214730\"
/></a></td>\n</tr>\n\n\n<tr class = debit
id=\"5\">\n\n\t<td>11/14/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\"amount\">$20.00</td>\t\t\n\t<td
class=\"divvy\">$-10.00</td>\n\n\t<td
class=\"runningbalance_debit\">$-20.00</td>\n\t\t\n\t\t
\n\t\t\n\t\t<td><a href=\"#\" onclick=\"new
Ajax.Request('/admin/edit/5', {asynchronous:true, evalScripts:true});
return false;\"><img alt=\"Edit\" border=\"0\"
src=\"/images/edit.png?1142214964\" /></a></td>\n\t\t\n\t\t<td><a
href=\"#\" onclick=\"new Ajax.Updater('register', '/admin/destroy/5',
{asynchronous:true, evalScripts:true}); return false;\"><img
alt=\"Destroy\" border=\"0\" src=\"/images/destroy.png?1142214730\"
/></a></td>\n</tr>\n\n\n<tr class = debit
id=\"14\">\n\n\t<td>11/14/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\"amount\">$10.00</td>\t\t\n\t<td
class=\"divvy\">$-5.00</td>\n\n\t<td
class=\"runningbalance_debit\">$-10.00</td>\n\t\t\n\t\t
\n\t\t\n\t\t<td><a href=\"#\" onclick=\"new
Ajax.Request('/admin/edit/14', {asynchronous:true, evalScripts:true});
return false;\"><img alt=\"Edit\" border=\"0\"
src=\"/images/edit.png?1142214964\" /></a></td>\n\t\t\n\t\t<td><a
href=\"#\" onclick=\"new Ajax.Updater('register', '/admin/destroy/14',
{asynchronous:true, evalScripts:true}); return false;\"><img
alt=\"Destroy\" border=\"0\" src=\"/images/destroy.png?1142214730\"
/></a></td>\n</tr>\n\n\n<tr id=
\"26\">\n\n\t<td>11/14/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>chris</td>\n\t<td
class=\"amount\">$20.00</td>\t\t\n\t<td
class=\"divvy\">$10.00</td>\n\n\t<td
class=\"runningbalance_debit\">$-5.00</td>\n\t\t\n\t\t
\n\t\t\n\t\t<td><a href=\"#\" onclick=\"new
Ajax.Request('/admin/edit/26', {asynchronous:true, evalScripts:true});
return false;\"><img alt=\"Edit\" border=\"0\"
src=\"/images/edit.png?1142214964\" /></a></td>\n\t\t\n\t\t<td><a
href=\"#\" onclick=\"new Ajax.Updater('register', '/admin/destroy/26',
{asynchronous:true, evalScripts:true}); return false;\"><img
alt=\"Destroy\" border=\"0\" src=\"/images/destroy.png?1142214730\"
/></a></td>\n</tr>\n\n\n<tr class = debit
id=\"27\">\n\n\t<td>11/14/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\"amount\">$10.00</td>\t\t\n\t<td
class=\"divvy\">$-5.00</td>\n\n\t<td
class=\"runningbalance_debit\">$-15.00</td>\n\t\t\n\t\t
\n\t\t\n\t\t<td><a href=\"#\" onclick=\"new
Ajax.Request('/admin/edit/27', {asynchronous:true, evalScripts:true});
return false;\"><img alt=\"Edit\" border=\"0\"
src=\"/images/edit.png?1142214964\" /></a></td>\n\t\t\n\t\t<td><a
href=\"#\" onclick=\"new Ajax.Updater('register', '/admin/destroy/27',
{asynchronous:true, evalScripts:true}); return false;\"><img
alt=\"Destroy\" border=\"0\" src=\"/images/destroy.png?1142214730\"
/></a></td>\n</tr>\n\n\n<tr class = debit
id=\"32\">\n\n\t<td>11/14/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\"amount\">$10.00</td>\t\t\n\t<td
class=\"divvy\">$-5.00</td>\n\n\t<td
class=\"runningbalance_debit\">$-10.00</td>\n\t\t\n\t\t
\n\t\t\n\t\t<td><a href=\"#\" onclick=\"new
Ajax.Request('/admin/edit/32', {asynchronous:true, evalScripts:true});
return false;\"><img alt=\"Edit\" border=\"0\"
src=\"/images/edit.png?1142214964\" /></a></td>\n\t\t\n\t\t<td><a
href=\"#\" onclick=\"new Ajax.Updater('register', '/admin/destroy/32',
{asynchronous:true, evalScripts:true}); return false;\"><img
alt=\"Destroy\" border=\"0\" src=\"/images/destroy.png?1142214730\"
/></a></td>\n</tr>\n\n\n<tr class = debit
id=\"20\">\n\n\t<td>11/12/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\"amount\">$10.00</td>\t\t\n\t<td
class=\"divvy\">$-5.00</td>\n\n\t<td
class=\"runningbalance_debit\">$-5.00</td>\n\t\t\n\t\t
\n\t\t\n\t\t<td><a href=\"#\" onclick=\"new
Ajax.Request('/admin/edit/20', {asynchronous:true, evalScripts:true});
return false;\"><img alt=\"Edit\" border=\"0\"
src=\"/images/edit.png?1142214964\" /></a></td>\n\t\t\n\t\t<td><a
href=\"#\" onclick=\"new Ajax.Updater('register', '/admin/destroy/20',
{asynchronous:true, evalScripts:true}); return false;\"><img
alt=\"Destroy\" border=\"0\" src=\"/images/destroy.png?1142214730\"
/></a></td>\n</tr>\n\n\n\n<tr class =\"debit\"
id=\"balance_fwd\">\n\t<td>11/1/2006</td>\n\t<td></td>\n\t<td>Balance
Forward</td>\n\t<td></td>\n\t<td class=\"amount\"></td>\t\t\n\t<td
class=\"divvy\"></td>\n\t<td
class=\"runningbalance_debit\">$-10.00</td>\n</tr>\n\n\t\t</tbody>\n</table>\n\n</div>\n</div>\n\n");
Element.update("nav", "<dt id=\"logo\">divvy</dt>\n\t \n\t\t<dd
id=\"t-logout\">\n\t\t<a href=\"/login/logout\">Log
out</a>\n\t</dd>\n\t\t\n\t<dd id=\"t-profile\">\n\t\t<a href=\"#\"
onclick=\"new Ajax.Request('/login/edit_user', {asynchronous:true,
evalScripts:true}); return false;\">Profile</a>\n\t</dd>\n\t<dd
id=\"selected\">\n\t\t<a href=\"#\" onclick=\"new
Ajax.Request('/admin/this_month', {asynchronous:true,
evalScripts:true}); return false;\">This Month</a>\n\t</dd>\n\t");
} catch (e) { alert('RJS error:\n\n' + e.toString());
alert('Element.update(\"content\", \"<div id=\\"payments\\">\n<div
id=\\"form\\">\n\t<form action=\\"/admin/create/23\\" method=\\"post\\"
onsubmit=\\"new Ajax.Request(\'/admin/create/23\', {asynchronous:true,
evalScripts:true, parameters:Form.serialize(this)}); return
false;\\">\n<table>\n\n<tr id=\\"form_row\\">\t\n\t<th
class=\\"date\\"><input id=\\"payment_date\\" name=\\"payment[date]\\"
order=\\"monthdayyear\\" size=\\"9\\" type=\\"text\\"
use_month_numbers=\\"true\\" value=\\"11/19/2006\\" /></th>\n\t<th
class=\\"payee\\"><input id=\\"payment_payee\\" maxsize=\\"15\\"
name=\\"payment[payee]\\" size=\\"12\\" type=\\"text\\"
value=\\"payee\\" /></th>\n \t<th class=\\"note\\"><input
id=\\"payment_note\\" maxsize=\\"17\\" name=\\"payment[note]\\"
size=\\"17\\" type=\\"text\\" value=\\"note\\" /></th>\n\t<th
class=\\"payer\\"><select id=\\"payment_payer\\"
name=\\"payment[payer]\\"><option
value=\\"chris\\">chris</option>\n<option value=\\"josh\\"
selected=\\"selected\\">josh</option></select></th>\n\t<th
class=\\"amount\\"><input id=\\"form_amount\\" maxsize=\\"8\\"
name=\\"payment[amount]\\" size=\\"7\\" type=\\"text\\"
value=\\"0.00\\" /></th>\n\t<th class=\\"divvy\\"
id=\\"form_submit\\"><input name=\\"commit\\" type=\\"submit\\"
value=\\"divvy!\\"
/></th>\n</tr>\n</form>\n</table>\n</div>\n\n<table>\n\t<tr
id=\\"register_header\\">\n\t\t<th class=\\"date\\"><a href=\\"#\\"
onclick=\\"new Ajax.Request(\'/admin/previous_month\',
{asynchronous:true, evalScripts:true}); return
false;\\"><<</a>\n\t\t\t\t\t\tdate\n\t\t\t\t\t\t<a href=\\"#\\"
onclick=\\"new Ajax.Request(\'/admin/next_month\', {asynchronous:true,
evalScripts:true}); return false;\\">>></a>\n\t\t\t\t\t\t</th>\n\t\t<th
class=\\"payee\\">payee</th><th class=\\"note\\">note</th><th
class=\\"payer\\">payer</th><th class=\\"amount\\"
id=\\"register_header_amount\\">amount</th><th class=\\"divvy\\"
id=\\"register_header_divvy\\">divvy</th><th
id=\\"register_header_runningbalance\\">balance</th><th><th></tr>\n\t\t<tbody
id=\\"register\\">\n\t\t\n\n<tr class = debit
id=\\"21\\">\n\n\t<td>11/16/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\\"amount\\">$10.00</td>\t\t\n\t<td
class=\\"divvy\\">$-5.00</td>\n\n\t<td
class=\\"runningbalance_debit\\">$-25.00</td>\n\t\t\n\t\t
  \n\t\t\n\t\t<td><a href=\\"#\\" onclick=\\"new
Ajax.Request(\'/admin/edit/21\', {asynchronous:true,
evalScripts:true}); return false;\\"><img alt=\\"Edit\\" border=\\"0\\"
src=\\"/images/edit.png?1142214964\\" /></a></td>\n\t\t\n\t\t<td><a
href=\\"#\\" onclick=\\"new Ajax.Updater(\'register\',
\'/admin/destroy/21\', {asynchronous:true, evalScripts:true}); return
false;\\"><img alt=\\"Destroy\\" border=\\"0\\"
src=\\"/images/destroy.png?1142214730\\" /></a></td>\n</tr>\n\n\n<tr
class = debit
id=\\"5\\">\n\n\t<td>11/14/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\\"amount\\">$20.00</td>\t\t\n\t<td
class=\\"divvy\\">$-10.00</td>\n\n\t<td
class=\\"runningbalance_debit\\">$-20.00</td>\n\t\t\n\t\t
  \n\t\t\n\t\t<td><a href=\\"#\\" onclick=\\"new
Ajax.Request(\'/admin/edit/5\', {asynchronous:true, evalScripts:true});
return false;\\"><img alt=\\"Edit\\" border=\\"0\\"
src=\\"/images/edit.png?1142214964\\" /></a></td>\n\t\t\n\t\t<td><a
href=\\"#\\" onclick=\\"new Ajax.Updater(\'register\',
\'/admin/destroy/5\', {asynchronous:true, evalScripts:true}); return
false;\\"><img alt=\\"Destroy\\" border=\\"0\\"
src=\\"/images/destroy.png?1142214730\\" /></a></td>\n</tr>\n\n\n<tr
class = debit
id=\\"14\\">\n\n\t<td>11/14/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\\"amount\\">$10.00</td>\t\t\n\t<td
class=\\"divvy\\">$-5.00</td>\n\n\t<td
class=\\"runningbalance_debit\\">$-10.00</td>\n\t\t\n\t\t
  \n\t\t\n\t\t<td><a href=\\"#\\" onclick=\\"new
Ajax.Request(\'/admin/edit/14\', {asynchronous:true,
evalScripts:true}); return false;\\"><img alt=\\"Edit\\" border=\\"0\\"
src=\\"/images/edit.png?1142214964\\" /></a></td>\n\t\t\n\t\t<td><a
href=\\"#\\" onclick=\\"new Ajax.Updater(\'register\',
\'/admin/destroy/14\', {asynchronous:true, evalScripts:true}); return
false;\\"><img alt=\\"Destroy\\" border=\\"0\\"
src=\\"/images/destroy.png?1142214730\\" /></a></td>\n</tr>\n\n\n<tr
id=
\\"26\\">\n\n\t<td>11/14/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>chris</td>\n\t<td
class=\\"amount\\">$20.00</td>\t\t\n\t<td
class=\\"divvy\\">$10.00</td>\n\n\t<td
class=\\"runningbalance_debit\\">$-5.00</td>\n\t\t\n\t\t
\n\t\t\n\t\t<td><a href=\\"#\\" onclick=\\"new
Ajax.Request(\'/admin/edit/26\', {asynchronous:true,
evalScripts:true}); return false;\\"><img alt=\\"Edit\\" border=\\"0\\"
src=\\"/images/edit.png?1142214964\\" /></a></td>\n\t\t\n\t\t<td><a
href=\\"#\\" onclick=\\"new Ajax.Updater(\'register\',
\'/admin/destroy/26\', {asynchronous:true, evalScripts:true}); return
false;\\"><img alt=\\"Destroy\\" border=\\"0\\"
src=\\"/images/destroy.png?1142214730\\" /></a></td>\n</tr>\n\n\n<tr
class = debit
id=\\"27\\">\n\n\t<td>11/14/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\\"amount\\">$10.00</td>\t\t\n\t<td
class=\\"divvy\\">$-5.00</td>\n\n\t<td
class=\\"runningbalance_debit\\">$-15.00</td>\n\t\t\n\t\t
  \n\t\t\n\t\t<td><a href=\\"#\\" onclick=\\"new
Ajax.Request(\'/admin/edit/27\', {asynchronous:true,
evalScripts:true}); return false;\\"><img alt=\\"Edit\\" border=\\"0\\"
src=\\"/images/edit.png?1142214964\\" /></a></td>\n\t\t\n\t\t<td><a
href=\\"#\\" onclick=\\"new Ajax.Updater(\'register\',
\'/admin/destroy/27\', {asynchronous:true, evalScripts:true}); return
false;\\"><img alt=\\"Destroy\\" border=\\"0\\"
src=\\"/images/destroy.png?1142214730\\" /></a></td>\n</tr>\n\n\n<tr
class = debit
id=\\"32\\">\n\n\t<td>11/14/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\\"amount\\">$10.00</td>\t\t\n\t<td
class=\\"divvy\\">$-5.00</td>\n\n\t<td
class=\\"runningbalance_debit\\">$-10.00</td>\n\t\t\n\t\t
  \n\t\t\n\t\t<td><a href=\\"#\\" onclick=\\"new
Ajax.Request(\'/admin/edit/32\', {asynchronous:true,
evalScripts:true}); return false;\\"><img alt=\\"Edit\\" border=\\"0\\"
src=\\"/images/edit.png?1142214964\\" /></a></td>\n\t\t\n\t\t<td><a
href=\\"#\\" onclick=\\"new Ajax.Updater(\'register\',
\'/admin/destroy/32\', {asynchronous:true, evalScripts:true}); return
false;\\"><img alt=\\"Destroy\\" border=\\"0\\"
src=\\"/images/destroy.png?1142214730\\" /></a></td>\n</tr>\n\n\n<tr
class = debit
id=\\"20\\">\n\n\t<td>11/12/2006</td>\n\t<td>payee</td>\n\t<td>note</td>\n\t<td>josh</td>\n\t<td
class=\\"amount\\">$10.00</td>\t\t\n\t<td
class=\\"divvy\\">$-5.00</td>\n\n\t<td
class=\\"runningbalance_debit\\">$-5.00</td>\n\t\t\n\t\t
\n\t\t\n\t\t<td><a href=\\"#\\" onclick=\\"new
Ajax.Request(\'/admin/edit/20\', {asynchronous:true,
evalScripts:true}); return false;\\"><img alt=\\"Edit\\" border=\\"0\\"
src=\\"/images/edit.png?1142214964\\" /></a></td>\n\t\t\n\t\t<td><a
href=\\"#\\" onclick=\\"new Ajax.Updater(\'register\',
\'/admin/destroy/20\', {asynchronous:true, evalScripts:true}); return
false;\\"><img alt=\\"Destroy\\" border=\\"0\\"
src=\\"/images/destroy.png?1142214730\\" /></a></td>\n</tr>\n\n\n\n<tr
class =\\"debit\\"
id=\\"balance_fwd\\">\n\t<td>11/1/2006</td>\n\t<td></td>\n\t<td>Balance
Forward</td>\n\t<td></td>\n\t<td class=\\"amount\\"></td>\t\t\n\t<td
class=\\"divvy\\"></td>\n\t<td
class=\\"runningbalance_debit\\">$-10.00</td>\n</tr>\n\n\t\t</tbody>\n</table>\n\n</div>\n</div>\n\n\");\nElement.update(\"nav\",
\"<dt id=\\"logo\\">divvy</dt>\n\t \n\t\t<dd id=\\"t-logout\\">\n\t\t<a
href=\\"/login/logout\\">Log out</a>\n\t</dd>\n\t\t\n\t<dd
id=\\"t-profile\\">\n\t\t<a href=\\"#\\" onclick=\\"new
Ajax.Request(\'/login/edit_user\', {asynchronous:true,
evalScripts:true}); return false;\\">Profile</a>\n\t</dd>\n\t<dd
id=\\"selected\\">\n\t\t<a href=\\"#\\" onclick=\\"new
Ajax.Request(\'/admin/this_month\', {asynchronous:true,
evalScripts:true}); return false;\\">This Month</a>\n\t</dd>\n\t\");');
throw e }

Any suggestions would be greatly appreciated.

Hi Josh,
Does your default layout contain the declaration to prototype.js?
You should have
  <%= javascript_include_tag :defaults %>
somewhere in the head of your index rhtml. One common place to put it
is in application.rhtml.

regards,
Dave

For what it's worth, I find that it's too easy to screw this up. I've
just been bitten (yet again) and all of my rjs/javascript is spewing
onto the page. simply by confusing when to use :url in a link_to caused
it:

    <%= link_to "Print Packing Slip", :url => {:controller =>
@controller_name, :action => 'print'},
        :popup => ['new_window', 'menubar,resizable=true'] %> ||

should be

    <%= link_to "Print Packing Slip", {:controller => @controller_name,
:action => 'print'},
        :popup => ['new_window', 'menubar,resizable=true'] %> ||

So, Josh, good luck. I'll send more random thoughts about this problem
as they come to me.Hope it helps!
Dave

you redirect_to a new action, which means the browser loads a new page.
so why do you want to render a RJS template anyway?
RJS templates are only meant for responding to an AJAX request, it
sends Javascript back to the brwoser WITHOUT loading a new page, and
prototype.js will execute the javascript an replace the corresponding
stuff.
now, if you redirect to a new page, the browser doesn't do an AJAX
request, but a normal HTTP request, and the javascript it gets served
by the server isn't evaluated.

sop are you even doing the login procedure via an AJAX call
(form_remote or sth.)?