Forum: Ruby on Rails Filtering main 'list' page

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
5cfe2c740d00a1b243e93ed79fdf3a1b?d=identicon&s=25 (Guest)
on 2007-07-11 20:53
(Received via mailing list)
Alright...I'm stuck again.  I'd appreciate any help.

I'm trying to 'filter' what is on my main page.  I'm using Apache LDAP
authentication and not the ror my username is passed through
using a variable.

I'm trying to filter the 'division_id' to a certain number...
basically, I want to do..

select * from responses WHERE division_id = '1';

I've tried to add stuff to the index and the list areas of the
controller, but it seems like I can't get it to filter out records
that should not be displayed for that username.  In the SQL query, it
looks correct in the development.log file...but it just doesn't
display correctly.

Thank you for any help!

3299251223f55753ec84719de39e6e53?d=identicon&s=25 Jon Garvin (Guest)
on 2007-07-11 22:02
(Received via mailing list) wrote:
@responses = Response.find(:all, :conditions => ['division_id =

Have read AWDWR yet?  Highly recommended!

5cfe2c740d00a1b243e93ed79fdf3a1b?d=identicon&s=25 (Guest)
on 2007-07-11 22:19
(Received via mailing list)
Thanks for the info.  Yeah, I've gone through AWDWR but still run into
problems every now and then.  I *finally* just got it working.  Here
is what's in my controller...

  def list
    @Division = %x("#{RAILS_ROOT}/ProtectedFiles/bin/"
    @responses = Response.find(:all, :conditions => ["division_id
= ?", @Division])

    # @response_pages, @responses = paginate :responses, :per_page =>

It turns out that if I uncomment that @response_pages line, for
whatever reason, it throughs everything off and does not run my
conditions filter.  But then, if I add the :conditions to that line
and comment out my query, everything works fine.

I suppose that's where I was getting stuck up at.  So now, here is my
final line where everything works great...

  def list
    @Division = %x("#{RAILS_ROOT}/ProtectedFiles/bin/"

    @response_pages, @responses = paginate :responses, :per_page =>
10, :conditions => ["division_id = ?", @Division]

Thank you for your help!!!

0900e6a4828bd989f96427082c6c74ca?d=identicon&s=25 Mike Garey (random52k)
on 2007-07-12 00:16
(Received via mailing list)
you can't paginate an already retrieved data set using the built in
rails pagination helpers.  You need to put your conditions into the
'paginate' method call, which it looks like you did the second time
around.  You might also want to look into using another paginator as
the built in pagination has been deprecated - the "will_paginate"
plugin is a good alternative.

This topic is locked and can not be replied to.