small medium large xlarge

Generic-user-small
15 Dec 2008, 18:36
zeb (1 post)

Hi, I’m a newbie to rails,

I have been reading chapter 17 and see objects are assigned to variables like this

order = Order.find(1)

I thought that instance variable started with a @

so it should be

@order = Order.find(1)

So what is this doing that I don’t understand,

Thanks

zeb

Samr_small_pragsmall
16 Dec 2008, 02:10
Sam Ruby (634 posts)

order (without an @) is a local variable, i.e., a variable scoped to the block of code which ceases to exist once that scope is exited.

You must be logged in to comment