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 -~----------~----~----~----~------~----~------~--~---
