Ruby on Rails Tuesday, February 10, 2015

I already posed my code, I have a paginated list with will_paginate obtained with a search query
the first page is shown correctly but the second is not shown with the js code because the query is not submitted for the second page with ajax code
the params[:q] is nil when I navigate to the second page
def index
    if !params[:q].nil?  
     
      @posts = Post.find_with_q.paginate(:per_page => 10, :page =>  params[:page])
     
      respond_to do |format|
        format.html # index.html.erb
        format.json { render json: @posts }
        format.js
      end
   end

end



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/20358cfb-2458-4ddd-b9e9-27c21e675017%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment