Jan 13, 2008
Generic-user-small Barry Simpson 1 post

Topic: Agile Web Development with Rails / self vs. @

I need some clarification on page 157 (2nd edition)—probably because I’m a newbie to both Ruby and Rails.

In the create_new_salt method, why wouldn’t you use @salt instead of self.salt? Don’t those mean the same thing? The text says you wouldn’t want to use salt = because Ruby would think you were referring to a local variable. That much is obvious to me already. But why wouldn’t you use @salt = , like most other places in the book, to assign to the instance variable?

Loving the book, by the way.

1 post