Hi! I think this will help you 
http://railscasts.com/episodes/240-search-sort-paginate-with-ajax

вторник, 10 февраля 2015 г., 13:05:51 UTC+3 пользователь Melb01 написал:
>
> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/236d236c-14ee-42eb-9c87-b69175a35fd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to