Wes,
This may also a good candidate for using constraints, especially if
the scaffold is nested or embedded into another view. This
requires :medical_facility_categories to be in the column set for the
medical_facilities scaffold. Nested scaffolds do the filtering
automatically, but would only work for one category at a time (if
nesting below categories). For embedding, you can:
render :active_scaffold => 'medical_facilities', :constraints =>
{:medical_facility_categories => @medical_facility_category_ids}
to embed the scaffold in another view, and the scaffold will hide that
column and filter by the ids in the instance variable.
Even if you aren't nesting/embedding the scaffold, you can inject the
constraints into AS using a before_filter to get the same results:
active_scaffold_session_storage[:constraints] ||=
@medical_facility_category_ids
But Sergio's method is probably cleaner for a non-nested or embedded
scaffold...
Hope this helps,
Ryan
On Mar 25, 10:33 am, Wes Gamble <[email protected]> wrote:
> Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
> wrote:
>
> > El Sunday 22 March 2009 08:17:18 Wes Gamble escribió:
>
> > I have a fairly complex custom find call that I need to do in some
> > instances for an AS index view. conditions_for_collection will only
> > handle conditions, correct? Is there any hook so that I can provide
> > other find options like :joins or :limit?
>
> > You can define an active_scaffold_joins method, like
> > active_scaffold_conditions, and you can set the limit in your controller AS
> > config:
> > config.list.per_page
> >http://wiki.github.com/activescaffold/active_scaffold/api-list
>
> Sergio,
>
> I need to do a join to a HABTM association table - currently I'm doing
> it as a subquery via conditions_for_collection, as in:
>
> "id IN (SELECT medical_facility_id FROM
> medical_facilities_medical_facility_categories WHERE
> medical_facility_category_id = #...@medical_facility_category_id})" if
> @medical_facility_category_id
>
> How would I write the active_scaffold_joins (or looks like I should use
> active_scaffold_habtm_joins) to handle this case?
>
> Thanks,
> Wes
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---