Hi Sergio Thanks for the response.
I have now experimented with active_scaffold_joins and it seems to accept symbols that represent direct associations of the object in question but NOT of indirect associations. For example lets assume that I have the following models: Arbitration -> Visit (Arbitration belongs_to Visit and Visit has_many Arbitrations) Visit -> Provider Provider -> Council Now if I want to list Arbitrations for a particular Provider I can join to Visit (direct association of Arbitration) and then match on provider_id (which will be on Visit). But, if I want to list Arbitrations for a particular Council there seems to be no way to do so using ActiveScaffold (using ActiveRecord I could optionally supply a SQL string as the :joins option to the find command). Have I missed something again? Any pointers would be appreciated. Thanks Regards, Tony On Feb 19, 11:33 pm, "Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::." <[email protected]> wrote: > El Thursday 19 February 2009 02:26:01 tonyday escribió: > > > Hi All > > > If I understand correctly there are currently two ways to control the > > set of records that the list action gets: > > > 1. Constraints > > Pass a constraints hash to the render method. This is limited to > > "equals only" on database fields of the primary object (not associated > > objects). > > > 2. conditions_for_collections > > Define a methods called conditions_for_collections. This allows for > > ActiveRecord style "conditions" (using either string or array syntax) > > but is also limited to database fields of the primary object. > > You are wrong. You can use fields from tables included in the query. > > > > > > > I have a situation that I believe calls for slightly more control - > > maybe somebody has some ideas. > > > Assume that I have the following associated models: > > > Supplier -> Master > > User -> Master > > Allocation -> Supplier > > Allocation -> User > > > (Allocation is the "many-to-many" between Supplier and User, Supplier > > and User both belong to Master). > > > Using ActiveRecord, if I have Supplier logged in and I want to display > > his Users (which he is associated to via Allocations) I can use the a > > combination of the :joins and :conditions clauses on the "find method" > > to join User to Supplier (through Allocation) and retrieve the > > relevant User records. > > > To do this in ActiveScaffold, a colleague has suggested building up an > > array of the relevant ids and then creating an "IN" condition passing > > in the array of ids (for example ['id IN (?)', array_of_ids]). > > This seems particularly kludgy and will also be quite non-performant > > as the count of ids grows. > > > Is there a more elegant way to do this in ActiveScaffold? > > > Any suggestions would be most welcome. > > Try to define active_scaffold_joins to set joins as you do with find from > ActiveRecord. > > -- > Sergio Cambra .:: entreCables S.L. ::. > Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza > T) 902 021 404 F) 976 52 98 07 E) [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en -~----------~----~----~----~------~----~------~--~---
