I''m trying to let users change attributes of their User objects...
their pw, e-mail, etc. For some reason it''s not updating. Pressing
the "update" button results in a screenful of javascript (from the rjs
template?). Don''t want to paste all of it, but here''s a
sample:
try {
Element.update("content", "<form
action=\"/login/update_user/1\"
method=\"post\">\n<table>\n\t<tr>\n\t\t<td>username</td>\n\t\t<td><input
id=\"user_name\" name=\"user[name]\" size=\"30\"
type=\"text\"
value=\"josh\"
/></td>\n\t</tr>\n\t<tr>\n\t\t<td>password</td>\n\t\t<td><div
class=\"fieldWithErrors\"><input id=\"user_password\"
name=\"user[password]\" size=\"30\"
type=\"password\" value=\"\"
/></div></td>\n\t</tr>\n\t<tr>\n\t\t<td>e-mail</td>\n\t\t<td><input
id=\"user_email\" name=\"user[email]\" size=\"30\"
type=\"text\"
value=\"\"
/></td>\n\t</tr>\n\t<tr>\n\t\t<td>roommate</td>\n\t\t<td><input
id=\"user_roommate\" name=\"user[roommate]\"
size=\"30\" type=\"text\"
value=\"chris\"
/></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td><input
type=\"submit\" value=\"Update Profile\"
/></td>\n\t</tr>\n</table>\n</form>\n<p>1\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-add_user\">\n\t\t<a href=\"#\"
onclick=\"new Ajax.Request(''/login/add_user'',
{asynchronous:true,
evalScripts:true}); return false;\">Add
user</a>\n\t</dd>\n\t<dd
id=\"t-list_users\">\n\t\t<a href=\"#\"
onclick=\"new
Ajax.Request(''/login/list_users'', {asynchronous:true,
evalScripts:true}); return false;\">List
users</a>\n\t</dd>\n\t\n\t<dd
id=\"selected\">\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=\"t-curmo\">\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(\ ....
Here''s my code:
from Login controller-
def edit_user
@user = User.find(:first, :conditions => ["name = ?",
"#{session[:user_name]}"])
end
def update_user
@user = User.find(params[:id])
if @user.update_attributes(params[:@user])
redirect_to_index("Profile updated.")
else
render :action => ''edit_user''
end
end
from edit_user template:
<%= form_tag :action => ''update_user'', :id => @user
%>
Any help would be greatly appreciated... (complete noobie at this
stuff!)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---