On Miércoles, 23 de Diciembre de 2009 11:28:50 [email protected] escribió:
> hi,
>
> i'm looking for a way to display only a subset of data in the index or
> list view without putting the condition in the view-template.
> What is the AS way to just pass the collection of model-objects to the
> list-template ?
> Can someone point me to the doc if there is any about this issue ?
>
> i'm trying to do something like this ..
>
> in controller
>
> def index
> if params[:cat] == 'o'
> @articles = Articles.sold_out
> else
> @articles = Articles.on_stock
> end
> end
>
> is the idea always to create a custom-view e.g like
> article_sold_out.haml and put the condition inside this view ?
No, is not the rails way to restrict records to show in a view. You should
restrict records with conditions option of find method. In ActiveScaffold you
can add conditions for the find method defining the method
conditions_for_collection in the controller:
def conditions_for_collection
{:sold_out => true}
end
We don't have support for named_scopes yet.
--
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 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.