Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find without dynamic finder #15

Open
cocodrino opened this issue May 2, 2011 · 2 comments
Open

find without dynamic finder #15

cocodrino opened this issue May 2, 2011 · 2 comments

Comments

@cocodrino
Copy link

hi...this is a pretty noob question....when I use find_by_email I get:

Warning: Defining view User#by_email with keys "email" at call time, please add it to the class body...
I don't know what must I do and use a method in call time result very slow and I'm used to datamapper style finder; there are any way for find whitout dynamic finder; I've tried it:

user=User.first(:name => "gaga") nice style datamapper
or

user=User.find(:first, :condition =>{:name => "gaga"}) ugly old rails version

but any work

thanks

@jweiss
Copy link
Collaborator

jweiss commented May 2, 2011

There is nothing wrong with calling User.find_by_email('[email protected]'). The warning just tells you that you probably want to define the view in the model so that it is obvious what views you have:

class User
  view :by_email. :keys => [:email]
end

If you define the view you can ask the class what views are available, e.g. when you refresh all your views.

@jweiss
Copy link
Collaborator

jweiss commented May 2, 2011

BTW once you called the method the first time, it gets defined, so there is nothing slow about it.

In CouchDB you cannot do fully dynamic queries. You would need to define a view first. This is what find_by_* does and why it warns you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants