Update command not updating DB


#1

I really need your help guys… I spent 6 hours on this simple update
command today that should work. It works fine in my other controller,
but doesn’t work in this one for some reason.

Here is my controller code for the list view, and then the update
command:

======
def edit
@user = User.find(params[:id])
end

def update
@user = User.find(params[:id])

if @user.update_attributes(@params[:users])
  redirect_to(:action => "save_account")
else
  flash[:notice] = "Couldn't save account information, please try 

again."
redirect_to(:action => ‘edit’, :id => @user.id)
end
end

if I set up a template for update and inspect both @user and
params[:user] this is what I get, in that same order:

======
#“test s address”, “shipping_state”=>“te”, “billing_street”=>“16409”,
“billing_city”=>“test”, “website”=>“www.test.com”,
“shipping_country”=>“test”, “shipping_zip”=>“test”, “id”=>“51”,
“shipping_city”=>“test”, “shipping_option”=>“1”, “billing_state”=>“te”,
“phone”=>“tttttttest”, “billing_country”=>“test”, “billing_zip”=>“test”,
“studio_name”=>“test studio”, “shipping_street”=>“test”,
“password”=>“4f939b7b470595d4c9924342ad57821cc818deac”, “login”=>“test”,
“email”=>“removed_email_address@domain.invalid”}>


{“shipping_state”=>“te”, “studio_address”=>“test s address”,
“billing_street”=>“testing”, “billing_city”=>“test”,
“website”=>“www.test.com”, “shipping_zip”=>“test”,
“shipping_country”=>“test”, “billing_state”=>“te”,
“shipping_city”=>“test”, “shipping_option”=>“1”, “phone”=>“tttttttest”,
“billing_country”=>“test”, “billing_zip”=>“test”, “studio_name”=>“test
studio”, “shipping_street”=>“test”}

Why is it that my @user starts with a # and never tells it that the
“test s address” is the studio address? Also, why does it end with }>? I
think my @user variable is why my .update_attributes command is failing
and never telling the SQL server to update itself. You will notice that
in my params I don’t include password, login, or email… but that is
because this is just editing user info and I don’t want re-access to
that info. Can someone please help me. Thanks a lot.


#2

Bryan C. wrote:

if @user.update_attributes(@params[:users])

Perhaps your problem is that you’re using @params here
rather than the params method which can handle both
symbol and string keys.


We develop, watch us RoR, in numbers too big to ignore.


#3

On 1/3/06, Mark Reginald J. removed_email_address@domain.invalid wrote:

if @user.update_attributes(@params[:users])

Is it just a typo that you are referencing @params[:users] here and
@params[:user] elsewhere in your message?


#4

Mark Reginald J. wrote:

Bryan C. wrote:

if @user.update_attributes(@params[:users])

Perhaps your problem is that you’re using @params here
rather than the params method which can handle both
symbol and string keys.


We develop, watch us RoR, in numbers too big to ignore.

I have used @params[:user], @params[“users”], and params[:users]… each
to no avail. Anyone?


#5

Lance B. wrote:

On 1/3/06, Mark Reginald J. removed_email_address@domain.invalid wrote:

if @user.update_attributes(@params[:users])

Is it just a typo that you are referencing @params[:users] here and
@params[:user] elsewhere in your message?

Yes, just a typo, sorry.


#6

Bryan C. wrote:

end
end
“shipping_city”=>“test”, “shipping_option”=>“1”, “billing_state”=>“te”,
“shipping_country”=>“test”, “billing_state”=>“te”,
because this is just editing user info and I don’t want re-access to
that info. Can someone please help me. Thanks a lot.

Look carefully at where you put your inspecting code in the template -
it looks to me as if it was inside an HTML helper call, so that the part
up to the first => in the @user was hidden inside the tag, and you have
ended up with }> in the content.

Doing View Source in the browser might help you to diagnose this.

regards

Justin