18:19 < Vagabond> how do I search the store for an instance? I can’t find any docs for select() or find()
18:20 < Vagabond> specifically I want to find the object that has a particular oid
(2 attempts)
Kashia answered:
Searching is a big field, this will just be a short introduction:
h3. If you have an OID already:
f = Foo[oid] # get the Foo object with given oid
h3. Searching for an OID with find()
f = Foo.find(:condition => "oid = #{oid}") # same here
h3. Searching for OID with select()
This is the most sophisticated out of those three, since you write pure SQL. A synonym for select is "find_by_sql".
f = Foo.select("SELECT * FROM ogfoo WHERE oid = #{oid}") f = Foo.select("WHERE oid = #{oid}")
The two statements above do the same thing actually, Og will automatically fill in the "SELECT * from
Hope that covers the question about searching for an oid. (Ask more question about more sophisticated search-queries if you like.)
manveru answered:
oh, well... not to forget
Foo.find_by_oid(oid) Foo.find_by_name(name) Foo.find_by_name_and_title(name, title) Foo.find_all_by_name(name) ....
and of course the new and shiny EZ-querying, even if nobody has a real idea how it works, it is said to be nice :)