I thought that the current implementation looked like a quick-fix! That
said, it solved an immediate problem, so I'll continue to use it until
what you proposed below comes along.
I like what I see below. My question would be, if I had three models,
ModelA, ModelB, and ModelC and all three had conditions and includes,
how would the statement look? Would it be:
ModelA.find_with_ferret(query, {
:page => 1, :per_page => 5,
:multi => {
:ModelB => { :conditions => ['b=?', b_Value ], :include =>
:some_B_relationship] },
:ModelC => { :conditions => ['c=?', c_Value ], :include =>
:some_C_relationship] },
}
},
{ :conditions => ['a=?', a_Value ], :include => :some_A_relationship]
} )
or would it be:
ModelA.find_with_ferret(query, {
:page => 1, :per_page => 5,
:multi => {
:ModelA => { :conditions => ['a=?', a_Value ], :include =>
:some_A_relationship] },
:ModelB => { :conditions => ['b=?', b_Value ], :include =>
:some_B_relationship] },
:ModelC => { :conditions => ['c=?', c_Value ], :include =>
:some_C_relationship] }
}
} )
In the first example, the conditions for ModelA are left hanging in the
find_options argument, as they would be with a single model search. The
second example is much cleaner, and is (I think) what happens internally
with the method call add_self_to_model_list_if_necessary(). The problem
with the second example, is that the syntax between a single model
search and multi-model search would be different.
Looking over the AAF code, perhaps it doesn't really matter. People
could use whatever syntax they're comfortable with.
The last question to ponder would be, what if I didn't have any
conditions or includes? Would it be
ModelA.find_with_ferret(query, {
:page => 1, :per_page => 5,
:multi => {
:ModelB => { },
:ModelC => { }
}
} )
I don't think I helped any, did I? What I can say, is I like bringing
the conditions into the :multi, rather than having to specify the :multi
as an array and then the conditions as a hash, but I can see the
inconsistencies it brings to the table.
Cheers,
- Sheldon Maloff
Jens Kraemer wrote:
> find_with_ferret query, :multi => {
> :model_a => { :conditions => ['a=?', a_Value ]
> },
> :model_b => { :include => :some_relationship }
> }
>
> What do you think?
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk