Is it just there as a default, to return itself, if a to_model doesn''t
override it on the model itself
On Sep 2, 6:05 pm, John Merlino <stoici...-YDxpq3io04c@public.gmane.org>
wrote:> There''s a number of calls in the Rails source to convert_to_model,
> which takes an activerecord object instance:
>
> convert_to_model(object)
>
> Here''s the thing. All convert_to_model does is calls to_model,
which
> returns self (the ActiveModel instance).
>
> Am I missing something here? Why call a method that returns the same
> thing?
>
> @user
>
> => #<User id: 3, name: "dscdsf", email:
"f...-kX2TDLzHGmnQT0dZR+AlfA@public.gmane.org",
> encrypted_password: "", phone: "9544443456", address:
"fvfdvf",
> reset_password_token: nil, reset_password_sent_at: nil,
> remember_created_at: nil, sign_in_count: 1, current_sign_in_at:
> "2011-09-27 17:01:45", last_sign_in_at: "2011-09-27
17:01:45",
> current_sign_in_ip: "127.0.0.1", last_sign_in_ip:
"127.0.0.1",
> created_at: "2011-09-12 16:55:30", updated_at: "2011-09-27
17:01:45",
> account_id: 1, role_id: 1, authentication_token: nil>
>
> @user.to_model
>
> => #<User id: 3, name: "dscdsf", email:
"f...-kX2TDLzHGmnQT0dZR+AlfA@public.gmane.org",
> encrypted_password: "", phone: "9544443456", address:
"fvfdvf",
> reset_password_token: nil, reset_password_sent_at: nil,
> remember_created_at: nil, sign_in_count: 1, current_sign_in_at:
> "2011-09-27 17:01:45", last_sign_in_at: "2011-09-27
17:01:45",
> current_sign_in_ip: "127.0.0.1", last_sign_in_ip:
"127.0.0.1",
> created_at: "2011-09-12 16:55:30", updated_at: "2011-09-27
17:01:45",
> account_id: 1, role_id: 1, authentication_token: nil>
>
> it returns the same exact thing...
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.