[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

user.attributes[:email] and user.email

tom

5/26/2006 8:45:00 AM

Hi

Could somebody explain to me why the following doesn't work:

@user = User.find(:first)
@user.attributes[:email] = params[:user][:email] # this does nothing!!
@user.save

but the following DOES work...

@user = User.find(:first)
@user.email = params[:user][:email] # this works like it should?!
@user.save

I only realized this when the @user.update_attributes(params[:user])
didn't seem to do anything. I was under the impression that the two
snippets above did the same thing?

Does anybody else have this problem with @user.update_attributes??

Thanks in advance

Tom Medhurst

9 Answers

loidee

5/26/2006 9:09:00 AM

0

the reason is because the @user has a variable defined as email but not
a variable of type array or hash, named attributes. I hope this helps,
if not let me know

tom

5/26/2006 9:15:00 AM

0

I probably should have mentioned that @user is a class that inherits
from ActiveRecord::Base.
so the attributes hash *should* be wired up the same as the
accessors..?
the @user.update_attributes was a line code-gen'ed by rails so why
wouldn't it work?

Codemonk

5/26/2006 3:29:00 PM

0

Because attributes creates a copy of the current values stored in a
hash, while when you assign the attribute directly you are changing the
value itself.

@user.attributes # This copies all of the current values of the @user
object into a hash
@user.attribute_name # is the actual value stored on the user object.

@user.attributes does NOT return a pointer to the underlying attributes
hash

loidee

5/27/2006 8:43:00 AM

0

i figured it was inherited from active record but i think codemonk
explains it quite well. i suppose the fact that there is a method
#update_attributes can be misleading and cause one to expect an actual
attributes hash

tom

5/28/2006 5:48:00 PM

0

thanks for the info!

john w

10/9/2008 1:20:00 PM

0

x-no-archive: yes
On Wed, 08 Oct 2008 22:02:11 -0800, ..... Matt .....
<trdell1234@nosgmail.com > wrote:
? 2008 John D Weatherly all rights reserved; no portion of this post
may be used anywhere else without written permission of the author.
>On Wed, 08 Oct 2008 20:05:22 -0700, john w <j<no>@yahoo.com> wrote:
>
>>x-no-archive: yes
>>On Tue, 07 Oct 2008 09:52:07 -0800, ..... Matt .....
>><trdell1234@nosgmail.com > wrote:
>> ? 2008 John D Weatherly all rights reserved; no portion of this post
>>may be used anywhere else without written permission of the author.
>>>On Tue, 07 Oct 2008 09:43:41 -0700, john w <j<no>@yahoo.com> wrote:
>>>
>>>>x-no-archive: yes
>>>>On Mon, 06 Oct 2008 11:58:50 -0800, ..... Matt .....
>>>><trdell1234@nosgmail.com > wrote:
>>>> ? 2008 John D Weatherly all rights reserved; no portion of this post
>>>>may be used anywhere else without written permission of the author.
>>>>>On Mon, 6 Oct 2008 14:34:52 -0400, "Robibnikoff"
>>>>><witchypoo@broomstick.com> wrote:
>>>>>
>>>>>>
>>>>>>"john w @yahoo.com>" <j<no> simpered:
>>>>>>
>>>>>>>
>>>>>>> Again, only according to your flawed logic.
>>>>>>
>>>>>>You appear to be off your meds, johnnie.
>>>>>
>>>>>
>>>>>Think he has been for over a week.
>>>>
>>>> Now you're saying that anyone who disagrees with your childish rants
>>>>is off their meds?
>>>>
>>>> Grow up.
>>>>
>>>>
>>>
>>>Yes Johnny we know that for me to agree with someone in another post
>>>that I started was a rant.
>>
>> You were talking about ME, you liar!
>
>Lets see I posted
>
>On Mon, 29 Sep 2008 11:06:23 -0400, DOC <NOSPAM@nospam> wrote:
>
>>On Sun, 28 Sep 2008 08:59:20 -0800, ... Matt .....
>><trdell1234@nsgmail.com > wrote:
>>
>>>
>>>How many of you want your Pastor or Priest telling you who to vote
>>>for. I for one don't. I also don't want any other non-profit group
>>>to do so. I would not give a dime to any non-pofit that did Church
>>>or not.
>>>
>>>Would you want the likes of Pat Robertson telling you who to vote for
>>>a man that at one time wanted terrorist to attack Orlando Florida.
>>>What of Phelps or Benny.
>>>
>>>God Bless
>>>
>>>Matt
>>
>>No one tells me who to vote for. That is my own personal decision. Any
>>church that dared try to tell me who to vote for, I would no longer
>>attend.
>
>
>My View completely.
>
>Matt
>
>****************************************
>
>How was that about you in any way?

That's not all you've said.

If it had ended there, I'd have no issue.

But rather than you saying I had mis-understood you (I didn't/ you
are re-posting VERY selectively)

You have begun a sassy, arrogant name-calling campaign (like you
didn't intend that), and you have been systematically, DELIBERATELY
calling me a name (a derivative of my name) , that you happen to KNOW
I don't like.

And now you want to pretend innocence!

A mature, rational, reasonable ADULT would have simply walked away.
You sense someone who is damaged and you just have to kick me around
for FUN.
Well, jerk, I kick back.

And you are no credit to the Jesus Christ you FALSELY claim to
serve!

You quote scripture! Satan does as well.

And you remain a jerk and a coward.



john w
>>
>>
>> You also do seem to be getting worst in
>>>the last few weeks.
>>
>> You are a liar.
>>
>> And my posts aren't mandatory.
>>
>> I'm about to stop reading yours; you might want to consider
>>sidestepping mine from now on.
>
>I don't follow you around you even attack post that are just
>scripture.
>
>Your just a freak.
>>
>>>
>>>I pray you get better
>>
>> Keep your prayers. Only the prayers of the RIGHTEOUS are answered.
>>And I am betting no Christian you know (from any unfortunate wife you
>>might have, to any unfortunate kids you might have, to any elders or
>>pastors you might have), would not appreciate what you're up to in
>>here.)
>
>Well I worry about you and incest. I pity you as you are just a
>freak.
>
>I pray for you.
>
>My kids are in college doing great. I pray your kid takes after his
>mother. In looks as well as brains.
>
>My wife has read many post here. We have been happily married for
>many decades. Sad you have not.
>
>Be Well freak
>
>Matt
>>
>> john w
>>
>> quote me scripture when you take scripture seriously.
>
>I take them seriously. You are just a hypocrite. Insane at that.
>
>
>>

john w

10/9/2008 1:21:00 PM

0

x-no-archive: yes
On Wed, 08 Oct 2008 22:02:11 -0800, ..... Matt .....
<trdell1234@nosgmail.com > wrote:
>On Wed, 08 Oct 2008 20:05:22 -0700, john w <j<no>@yahoo.com> wrote:
>
>>x-no-archive: yes
>>On Tue, 07 Oct 2008 09:52:07 -0800, ..... Matt .....
>><trdell1234@nosgmail.com > wrote:
>> ? 2008 John D Weatherly all rights reserved; no portion of this post
>>may be used anywhere else without written permission of the author.
>>>On Tue, 07 Oct 2008 09:43:41 -0700, john w <j<no>@yahoo.com> wrote:
>>>
>>>>x-no-archive: yes
>>>>On Mon, 06 Oct 2008 11:58:50 -0800, ..... Matt .....
>>>><trdell1234@nosgmail.com > wrote:
>>>> ? 2008 John D Weatherly all rights reserved; no portion of this post
>>>>may be used anywhere else without written permission of the author.
>>>>>On Mon, 6 Oct 2008 14:34:52 -0400, "Robibnikoff"
>>>>><witchypoo@broomstick.com> wrote:
>>>>>
>>>>>>
>>>>>>"john w @yahoo.com>" <j<no> simpered:
>>>>>>
>>>>>>>
>>>>>>> Again, only according to your flawed logic.
>>>>>>
>>>>>>You appear to be off your meds, johnnie.
>>>>>
>>>>>
>>>>>Think he has been for over a week.
>>>>
>>>> Now you're saying that anyone who disagrees with your childish rants
>>>>is off their meds?
>>>>
>>>> Grow up.
>>>>
>>>>
>>>
>>>Yes Johnny we know that for me to agree with someone in another post
>>>that I started was a rant.
>>
>> You were talking about ME, you liar!
>
>Lets see I posted
>
>On Mon, 29 Sep 2008 11:06:23 -0400, DOC <NOSPAM@nospam> wrote:
>
>>On Sun, 28 Sep 2008 08:59:20 -0800, ... Matt .....
>><trdell1234@nsgmail.com > wrote:
>>
>>>
>>>How many of you want your Pastor or Priest telling you who to vote
>>>for. I for one don't. I also don't want any other non-profit group
>>>to do so. I would not give a dime to any non-pofit that did Church
>>>or not.
>>>
>>>Would you want the likes of Pat Robertson telling you who to vote for
>>>a man that at one time wanted terrorist to attack Orlando Florida.
>>>What of Phelps or Benny.
>>>
>>>God Bless
>>>
>>>Matt
>>
>>No one tells me who to vote for. That is my own personal decision. Any
>>church that dared try to tell me who to vote for, I would no longer
>>attend.
>
>
>My View completely.
>
>Matt
>
>****************************************
>
>How was that about you in any way?
>>
>>
>> You also do seem to be getting worst in
>>>the last few weeks.
>>
>> You are a liar.
>>
>> And my posts aren't mandatory.
>>
>> I'm about to stop reading yours; you might want to consider
>>sidestepping mine from now on.
>
>I don't follow you around you even attack post that are just
>scripture.
>
>Your just a freak.
>>
>>>
>>>I pray you get better
>>
>> Keep your prayers. Only the prayers of the RIGHTEOUS are answered.
>>And I am betting no Christian you know (from any unfortunate wife you
>>might have, to any unfortunate kids you might have, to any elders or
>>pastors you might have), would not appreciate what you're up to in
>>here.)
>
>Well I worry about you and incest. I pity you as you are just a
>freak.
>
>I pray for you.
>
>My kids are in college doing great. I pray your kid takes after his
>mother. In looks as well as brains.
>
>My wife has read many post here. We have been happily married for
>many decades. Sad you have not.
>
>Be Well freak
>
>Matt
>>
>> john w

-------------- ARCHIVED ------------------
>>
>> quote me scripture when you take scripture seriously.
>
>I take them seriously. You are just a hypocrite. Insane at that.
>
>
>>

john w

10/9/2008 1:25:00 PM

0

x-no-archive: yes
On Wed, 08 Oct 2008 22:02:11 -0800, ..... Matt .....
<trdell1234@nosgmail.com > wrote:
? 2008 John D Weatherly all rights reserved; no portion of this post
may be used anywhere else without written permission of the author.
>On Wed, 08 Oct 2008 20:05:22 -0700, john w <j<no>@yahoo.com> wrote:
>
>>x-no-archive: yes
>>On Tue, 07 Oct 2008 09:52:07 -0800, ..... Matt .....
>><trdell1234@nosgmail.com > wrote:
>> ? 2008 John D Weatherly all rights reserved; no portion of this post
>>may be used anywhere else without written permission of the author.
>>>On Tue, 07 Oct 2008 09:43:41 -0700, john w <j<no>@yahoo.com> wrote:
>>>
>>>>x-no-archive: yes
>>>>On Mon, 06 Oct 2008 11:58:50 -0800, ..... Matt .....
>>>><trdell1234@nosgmail.com > wrote:
>>>> ? 2008 John D Weatherly all rights reserved; no portion of this post
>>>>may be used anywhere else without written permission of the author.
>>>>>On Mon, 6 Oct 2008 14:34:52 -0400, "Robibnikoff"
>>>>><witchypoo@broomstick.com> wrote:
>>>>>
>>>>>>
>>>>>>"john w @yahoo.com>" <j<no> simpered:
>>>>>>
>>>>>>>
>>>>>>> Again, only according to your flawed logic.
>>>>>>
>>>>>>You appear to be off your meds, johnnie.
>>>>>
>>>>>
>>>>>Think he has been for over a week.
>>>>
>>>> Now you're saying that anyone who disagrees with your childish rants
>>>>is off their meds?
>>>>
>>>> Grow up.
>>>>
>>>>
>>>
>>>Yes Johnny we know that for me to agree with someone in another post
>>>that I started was a rant.
>>
>> You were talking about ME, you liar!
>
>Lets see I posted
>
>On Mon, 29 Sep 2008 11:06:23 -0400, DOC <NOSPAM@nospam> wrote:
>
>>On Sun, 28 Sep 2008 08:59:20 -0800, ... Matt .....
>><trdell1234@nsgmail.com > wrote:
>>
>>>
>>>How many of you want your Pastor or Priest telling you who to vote
>>>for. I for one don't. I also don't want any other non-profit group
>>>to do so. I would not give a dime to any non-pofit that did Church
>>>or not.
>>>
>>>Would you want the likes of Pat Robertson telling you who to vote for
>>>a man that at one time wanted terrorist to attack Orlando Florida.
>>>What of Phelps or Benny.
>>>
>>>God Bless
>>>
>>>Matt
>>
>>No one tells me who to vote for. That is my own personal decision. Any
>>church that dared try to tell me who to vote for, I would no longer
>>attend.
>
>
>My View completely.
>
>Matt
>
>****************************************
>
>How was that about you in any way?
>>
>>
>> You also do seem to be getting worst in
>>>the last few weeks.
>>
>> You are a liar.
>>
>> And my posts aren't mandatory.
>>
>> I'm about to stop reading yours; you might want to consider
>>sidestepping mine from now on.
>
>I don't follow you around you even attack post that are just
>scripture.
>
>Your just a freak.

If you think that bothers me, you're dumber than a brick.
>>
>>>
>>>I pray you get better
>>
>> Keep your prayers. Only the prayers of the RIGHTEOUS are answered.
>>And I am betting no Christian you know (from any unfortunate wife you
>>might have, to any unfortunate kids you might have, to any elders or
>>pastors you might have), would not appreciate what you're up to in
>>here.)
>
>Well I worry about you and incest.

Dipshit, you don't have a friggin clue!

I pity you as you are just a
>freak.

snicker.

You need to try harder than that.
Asshole.
>
>I pray for you.
>
>My kids are in college doing great. I pray your kid takes after his
>mother. In looks as well as brains.

I'm betting when they find out what you're up to in here, they'll
turn on you; they certainly will if they have any character.
You being their father, that's doubtful.

>
>My wife has read many post here.

I don't believe you. And if she has read your posts to me, and she
thinks they're just fine, she's no better than you. Just plain low.

We have been happily married for
>many decades. Sad you have not.

Anyone who thinks you're wonderful is lower than what I scrape off
my shoes.


>
>Be Well freak
>
>Matt
>>
>> john w
>>
>> quote me scripture when you take scripture seriously.
>
>I take them seriously.

You obviously don't.

You have no respect.

You are just a hypocrite.

snicker. Coming from you, ^ ^ ^ That's hilarious!

Insane at that.

^ ^ ^ ^ Not even close.

I was evaluated a month ago. When did you have YOUR last psych
eval?
I'm betting never! Meaning, you're a walking sociopath.

And a dumb shit, and an asshole.

>
>
>>

john w

10/9/2008 1:26:00 PM

0

x-no-archive: yes
On Wed, 08 Oct 2008 22:02:11 -0800, ..... Matt .....
<trdell1234@nosgmail.com > wrote:
? 2008 John D Weatherly all rights reserved; no portion of this post
may be used anywhere else without written permission of the author.
>On Wed, 08 Oct 2008 20:05:22 -0700, john w <j<no>@yahoo.com> wrote:
>
>>x-no-archive: yes
>>On Tue, 07 Oct 2008 09:52:07 -0800, ..... Matt .....
>><trdell1234@nosgmail.com > wrote:
>> ? 2008 John D Weatherly all rights reserved; no portion of this post
>>may be used anywhere else without written permission of the author.
>>>On Tue, 07 Oct 2008 09:43:41 -0700, john w <j<no>@yahoo.com> wrote:
>>>
>>>>x-no-archive: yes
>>>>On Mon, 06 Oct 2008 11:58:50 -0800, ..... Matt .....
>>>><trdell1234@nosgmail.com > wrote:
>>>> ? 2008 John D Weatherly all rights reserved; no portion of this post
>>>>may be used anywhere else without written permission of the author.
>>>>>On Mon, 6 Oct 2008 14:34:52 -0400, "Robibnikoff"
>>>>><witchypoo@broomstick.com> wrote:
>>>>>
>>>>>>
>>>>>>"john w @yahoo.com>" <j<no> simpered:
>>>>>>
>>>>>>>
>>>>>>> Again, only according to your flawed logic.
>>>>>>
>>>>>>You appear to be off your meds, johnnie.
>>>>>
>>>>>
>>>>>Think he has been for over a week.
>>>>
>>>> Now you're saying that anyone who disagrees with your childish rants
>>>>is off their meds?
>>>>
>>>> Grow up.
>>>>
>>>>
>>>
>>>Yes Johnny we know that for me to agree with someone in another post
>>>that I started was a rant.
>>
>> You were talking about ME, you liar!
>
>Lets see I posted
>
>On Mon, 29 Sep 2008 11:06:23 -0400, DOC <NOSPAM@nospam> wrote:
>
>>On Sun, 28 Sep 2008 08:59:20 -0800, ... Matt .....
>><trdell1234@nsgmail.com > wrote:
>>
>>>
>>>How many of you want your Pastor or Priest telling you who to vote
>>>for. I for one don't. I also don't want any other non-profit group
>>>to do so. I would not give a dime to any non-pofit that did Church
>>>or not.
>>>
>>>Would you want the likes of Pat Robertson telling you who to vote for
>>>a man that at one time wanted terrorist to attack Orlando Florida.
>>>What of Phelps or Benny.
>>>
>>>God Bless
>>>
>>>Matt
>>
>>No one tells me who to vote for. That is my own personal decision. Any
>>church that dared try to tell me who to vote for, I would no longer
>>attend.
>
>
>My View completely.
>
>Matt
>
>****************************************
>
>How was that about you in any way?
>>
>>
>> You also do seem to be getting worst in
>>>the last few weeks.
>>
>> You are a liar.
>>
>> And my posts aren't mandatory.
>>
>> I'm about to stop reading yours; you might want to consider
>>sidestepping mine from now on.
>
>I don't follow you around you even attack post that are just
>scripture.
>
>Your just a freak.
>>
>>>
>>>I pray you get better
>>
>> Keep your prayers. Only the prayers of the RIGHTEOUS are answered.
>>And I am betting no Christian you know (from any unfortunate wife you
>>might have, to any unfortunate kids you might have, to any elders or
>>pastors you might have), would not appreciate what you're up to in
>>here.)
>
>Well I worry about you and incest. I pity you as you are just a
>freak.
>
>I pray for you.
>
>My kids are in college doing great. I pray your kid takes after his
>mother. In looks as well as brains.
>
>My wife has read many post here. We have been happily married for
>many decades. Sad you have not.
>
>Be Well freak
>
>Matt
>>
>> john w
>>
>> quote me scripture when you take scripture seriously.
>
>I take them seriously. You are just a hypocrite. Insane at that.
>
>
Show me the verses that approve your actions. LIAR!

-------------- ARCHIVED ------------------
>>