Hi,
I'm building a site for posting opinions and I have categories for opinions.
When a user click an opinion category, an ajax request is sent to the server.
The results are then updated on the page.
I'm trying to build will_pagination into the site, but its not set up for ajax. I found this link github, which provides an example but I can't seem to get it to work. It just puts an image on the screen. Does anyone know how to set up will_pagination with ajax links and updates?
This is the code I wrote to get the categories for the opinions:
def category_content
#check that params is valid category
type = params[:id]
test = false
get_category_list.each do |c|
if c.eql?(type)
test = true
end
end
unless test.equal?(true) && request.xhr?
redirect_to(profile_opinions_path(session[:user]))
else
if type.eql?('Recent')
@recent_list = Opinion.find(:all, :order => "created_at DESC", :limit => 10)
render :partial => 'opinions/opinion_update/category_content'
else
@opinion_list = Opinion.paginate :page => params[:page],
:include => :categories,
:conditions => ['categories.category = ?', type],
:order => "opinions.created_at DESC"
render :partial => 'opinions/opinion_update/category_content'
end
end
end
There's three tables in a many-to-many relationship. The join table contains the category for the opinion.