Gene Kahn wrote:> How do I display subsets of records on a Listing page (that lists in
> grid form table records)? In particular, when displaying the Listing
> page, it would be nice to allow the user to display a subset of the
> records, for example, by filtering.
>
> For example, I have the following Controller Listing and Filtering
> actions:
>
> def list
> @eng_sense_pages, @eng_senses = paginate :eng_senses, :per_page =>
> 10
> end
>
> def filter_by_synset_offset
> @eng_senses =
> EngSense.find_by_synset_offset(params[:synset_offset])
> if @eng_senses
> redirect_to :action => ''list''
> else
> flash[:notice] = "Unable to find English synset offset:
> #{:synset_offset}"
> end
> end
>
> However, the resulting display shows the full table, not the filtered
> subset. Is this because of the directive: @ng_senses = paginate
> :eng_senses, in the definition of the lists?
>
> How does one display a subset of the table records in a grid display?
>
> Thanks!
> gk
maybe you can use the :condition in the paginate, as I do when searching
:
conditions = ["synset_offset LIKE ?",
"%#{@params[:synset_offset]}%"]
unless @params[:synset_offset].nil?
@ eng_sense_pages, @ eng_senses = paginate(:eng_senses,
:conditions => conditions, :per_page => 10)
--
Posted via http://www.ruby-forum.com/.