El Dorado

A full-stack community web application written in Ruby/Rails
Problems with Filters « El Dorado « almost effortless
 
Tue, 07 Apr 2009, 07:35am #1
Fearless Freep
Member
Registered: July 2008
Last visit: Tue, 02 Feb 2010
Posts: 29

Trevor,

Got back to working on my mods recently, and am running into a problem that makes me think I'm having some sort of problem understanding Rails. I've been just trying to do a simple filter on results. I tried creating a view which was basically just a copy of posts/show.html.erb, as named in the sample code below. As you see, I just want to limit results to records with a specific 'id' and 'reference_id,' a new field in posts, but I only get one record showing up, the one with the matching 'post_id'. I've also tried rendering 'topics/show', and all the records in posts show up there. I've also tried using just a post.find in place of post.paginate, unsuccessfully

What am I missing in my approach here?

Sample:
def filter_proc
@posts = Post.paginate(:page => params[:page], :conditions => reference_id = params[:post_id] || id = params[:post_id])
render :template => 'posts/filter_proc'
end

Offline
Tue, 07 Apr 2009, 07:38am #2
Trevor
Administrator
Costco2
Registered: September 2005
Last visit: 16 hours ago
Posts: 370

If you upload your stuff to github and send me link to there, I might be able to help. I can't really tell what you're trying to accomplish or what's going wrong from here, though.

Offline
Tue, 07 Apr 2009, 07:48am #3
Fearless Freep
Member
Registered: July 2008
Last visit: Tue, 02 Feb 2010
Posts: 29

Okay, I'll get on that. Thanks.

Offline