I thought they where attr_accessor method.

Thank you for clearing things up for me.


On Monday, January 30, 2012, Peter Vandenabeele <[email protected]>
wrote:
> On Mon, Jan 30, 2012 at 9:59 PM, Rodrigo Ruiz <[email protected]>
wrote:
>>
>> Thank you, but I knew that, I did that (use self to do what I want)
before I asked the question.
>> I'd just like to know why can't I use @first_name instead of
self.first_name, to me it seems like the same thing inside the model.
>
> They are not:
> @first_name is an "instance variable". You could set it like this:
>   @first_name = user.first_name
> but it is not automatically set, and it is also not typically used like
that.
> A more typical use would be:
> @user = User.find(params[:id])
> and then you can use @user in the controller, but also in the views,
> due to the set-up of Rails.
> self.first_name is a method that is dynamically provided by
> ActiveRecord , based on the available columns for the table
> "users" in the database.
> HTH,
> Peter
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to
[email protected].
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to