Override .find, .find_by_id, etc

I read these:
http://www.ruby-forum.com/topic/185297#new
http://www.freezzo.com/2008/05/14/override-default-find-conditions-for-model/

it works, it override the .find perfectly, however it does not cover
.find_by_id or other .find_by_XXX

Is there anyway to override all the find function of a modal? I want to
set the default “select” for User modal, only return name and id, but
not the password by default.

Thanks

On Dec 28, 9:54 am, Leonardo W. [email protected] wrote:

I read these:How to properly override ActiveRecord::Base.find - Rails - Ruby-Forum

it works, it override the .find perfectly, however it does not cover
.find_by_id or other .find_by_XXX

Is there anyway to override all the find function of a modal? I want to
set the default “select” for User modal, only return name and id, but
not the password by default.

default_scope ?

The methods linked above should also work in recent versions of rails

  • find_by_xxx used to call find_every/find_initial directly but now
    calls find.

Fred

Thanks

Posted viahttp://www.ruby-forum.com/.

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.

Thanks! I am using a very old version rails… thats why it does not
work…
I tested on new version rails and it works, happy now =)

Leonardo

Frederick C. wrote:

On Dec 28, 9:54�am, Leonardo W. [email protected] wrote:

I read these:How to properly override ActiveRecord::Base.find - Rails - Ruby-Forum

it works, it override the .find perfectly, however it does not cover
.find_by_id or other .find_by_XXX

Is there anyway to override all the find function of a modal? I want to
set the default “select” for User modal, only return name and id, but
not the password by default.

default_scope ?

The methods linked above should also work in recent versions of rails

  • find_by_xxx used to call find_every/find_initial directly but now
    calls find.

Fred

Thanks

Posted viahttp://www.ruby-forum.com/.

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.