Open cocodrino opened 13 years ago
There is nothing wrong with calling User.find_by_email('abc@example.com')
. 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.
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 findby* does and why it warns you.
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