wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-11 18:52 UTC
Filtering main ''list'' page
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 one...so 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! mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> 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 one...so 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! > > mike > >@responses = Response.find(:all, :conditions => [''division_id ?'',@division_id]) Have read AWDWR yet? Highly recommended! http://www.pragmaticprogrammer.com/titles/rails/ -- http://www.5valleys.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jul-11 20:18 UTC
Re: Filtering main ''list'' page
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/adlookup2.pl" #{ENV[''Username'']}) @responses = Response.find(:all, :conditions => ["division_id = ?", @Division]) # @response_pages, @responses = paginate :responses, :per_page => 10 end 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/adlookup2.pl" #{ENV[''Username'']}) @response_pages, @responses = paginate :responses, :per_page => 10, :conditions => ["division_id = ?", @Division] end Thank you for your help!!! Mike On Jul 11, 3:01 pm, Jon Garvin <jgarvin.li...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > 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 one...so 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! > > > mike > > @responses = Response.find(:all, :conditions => [''division_id > ?'',@division_id]) > > Have read AWDWR yet? Highly recommended!http://www.pragmaticprogrammer.com/titles/rails/ > > --http://www.5valleys.com/--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. Mike On 7/11/07, wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <wiz561-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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/adlookup2.pl" > #{ENV[''Username'']}) > > @responses = Response.find(:all, :conditions => ["division_id > = ?", @Division]) > > # @response_pages, @responses = paginate :responses, :per_page => > 10 > end > > 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/adlookup2.pl" > #{ENV[''Username'']}) > > @response_pages, @responses = paginate :responses, :per_page => > 10, :conditions => ["division_id = ?", @Division] > end > > > > Thank you for your help!!! > > Mike > > > > > On Jul 11, 3:01 pm, Jon Garvin <jgarvin.li...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > wiz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > 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 one...so 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! > > > > > mike > > > > @responses = Response.find(:all, :conditions => [''division_id > > ?'',@division_id]) > > > > Have read AWDWR yet? Highly recommended!http://www.pragmaticprogrammer.com/titles/rails/ > > > > --http://www.5valleys.com/ > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---