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
\n\t\t<tbody id=“register”>\n\t\t\n\n<tr class = debit id=“21”>\n\n\t |
11/16/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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" /> | \n\t\t\n\t\t<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" /> | \n\n\n\n<tr class = debit11/14/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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" /> | \n\t\t\n\t\t<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" /> | \n\n\n\n<tr class = debit11/14/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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" /> | \n\t\t\n\t\t<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" /> | \n\n\n\n<tr id=11/14/2006 | \n\tpayee | \n\tnote | \n\tchris | \n\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" /> | \n\t\t\n\t\t<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" /> | \n\n\n\n<tr class = debit11/14/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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" /> | \n\t\t\n\t\t<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" /> | \n\n\n\n<tr class = debit11/14/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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" /> | \n\t\t\n\t\t<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" /> | \n\n\n\n<tr class = debit11/12/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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" /> | \n\t\t\n\t\t<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" /> | \n\n\n\n\n<tr class =“debit”11/1/2006 | \n\t\n\t | Balance Forward | \n\t\n\t<td class=“amount”>\t\t\n\t<td |
---|
Element.update(“nav”, “<dt id=“logo”>divvy\n\t \n\t\t<dd
id=“t-logout”>\n\t\t<a href=”/login/logout">Log
out\n\t\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\n\t\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\n\t\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
\n\t\t<tbody id=\“register\”>\n\t\t\n\n<tr class = debit id=\“21\”>\n\n\t |
11/16/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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\" /> | \n\t\t\n\t\t<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\" /> | \n\n\n\n<tr11/14/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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\" /> | \n\t\t\n\t\t<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\" /> | \n\n\n\n<tr11/14/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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\" /> | \n\t\t\n\t\t<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\" /> | \n\n\n\n<tr11/14/2006 | \n\tpayee | \n\tnote | \n\tchris | \n\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\" /> | \n\t\t\n\t\t<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\" /> | \n\n\n\n<tr11/14/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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\" /> | \n\t\t\n\t\t<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\" /> | \n\n\n\n<tr11/14/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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\" /> | \n\t\t\n\t\t<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\" /> | \n\n\n\n<tr11/12/2006 | \n\tpayee | \n\tnote | \n\tjosh | \n\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\" /> | \n\t\t\n\t\t<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\" /> | \n\n\n\n\n<tr11/1/2006 | \n\t\n\t | Balance Forward | \n\t\n\t<td class=\“amount\”>\t\t\n\t<td |
---|
“<dt id=\“logo\”>divvy\n\t \n\t\t<dd id=\“t-logout\”>\n\t\t<a
href=\”/login/logout\">Log out\n\t\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\n\t\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\n\t\n\t");’);
throw e }
Any suggestions would be greatly appreciated.