will-paginate

Rails3/will_paginate/Ajax - next/previous link doesn't work properly (is it a bug?)

烈酒焚心 提交于 2019-12-21 22:07:24
问题 I am following the "Pagination with ajax" railscast for my rails 3 application. Everything seems to work great, except the fact that Previous and next links don't work at all. Basically, It appears that the previous link is stuck even if I click on other pages, (when I am on the user/show page1) The "next link" works one time till the page 2 (I can't use it after) Numbers didn't update when I come to "..." I would be pleased to know if someone experience the same problem (a bug?) or if my

How to paginate sunspot in this manner?

我只是一个虾纸丫 提交于 2019-12-21 21:52:57
问题 I have the following model associations: class Product < ActiveRecord::Base has_many :prices class Price < ActiveRecord::Base belongs_to :product Here is my controller class SearchController < ApplicationController # Using Sunspot here. def index @search = Product.search do fulltext params[:search] paginate(:per_page => 5, :page => params[:page]) end @products = @search.results end end and then my view: <%= will_paginate @products %> <% @products.each do |product| %> <%= product.name %> <%

rails pagination - different per_page value page 1 from subsequent pages

一世执手 提交于 2019-12-21 06:27:14
问题 I have kinda blog/wiki application where I'd like the home page to include a welcome/landing message and the 5 most recent blog entries and pagination linking to older entries. Is it possible to have, for example, 5 pages returned as page one of paginated search results and 15 for subsequent pages? I'm currently using will_paginate. 回答1: You can use WillPaginate::Collection , here is an example you can use for this : def self.find_with_pagination(params = {}) WillPaginate::Collection.create

How best to DRY will_paginate options

狂风中的少年 提交于 2019-12-21 04:08:45
问题 I have 8 controllers using will_paginate to paginate their index pages. I'd like to override the defaults for "Previous" and "Next" on each without having to specify the same options 8 times. Is there a way to override the defaults only once (perhaps by subclassing will_paginate). 回答1: will_paginate uses I18n so you can just use that. Given you use English as the default locale the following line should be present in application.rb : config.i18n.default_locale = :en you can then change the

Deprecation warning: #apply_finder_options

纵饮孤独 提交于 2019-12-21 04:01:04
问题 I get DEPRECATION WARNING: #apply_finder_options is deprecated. when trying this in my user.rb : def User.search(search, page) paginate page: page, per_page: 10, conditions: ['name LIKE ?', "%#{search}%"], order: 'name' end Called through UsersController : def index @users = User.search(params[:search], params[:page]) end The pagination is done with the will_paginate gem. What is triggering the warning and how can I fix it? Been trying some googling, but I find the docs not too comprehensive!

Rails3: How to pass param into custom will_paginate renderer?

南楼画角 提交于 2019-12-21 03:42:56
问题 I've got a custom will_paginate renderer that overrides WillPaginate::ViewHelpers::LinkRenderer's link method like so: def link(text, target, attributes = {}) "<a href='/users/95/friends_widget?page=#{target}' rel='next' data-remote='true'>#{text}</a>" end ...and that works great, except you can see the hard-coded 95 in that link. How would I pass a parameter (e.g. user or user's ID) into the custom renderer via the Rails view? <%= will_paginate(@user_friends, :remote => true, :renderer =>

undefined method `will_paginate', Rails 3.1 / DataMapper

筅森魡賤 提交于 2019-12-20 03:09:17
问题 Newly installed will_paginate 3.0.0 gem 'will_paginate', '~> 3.0.0', :require=>'will_paginate/data_mapper' Running a controller query: @tickets = Ticket.paginate(:page => params[:page], :per_page => 5,:username => @ticket.username) Which works, pulls up all the tickets for a user and paginates in 5's if I put ?page=X where x is a page number in the url. =will_paginate(@tickets) in the view does not work, this results in undefined method `will_paginate' for #<#<Class:0x000000053674c8>

get will_paginate to define a custom offset on the first page

一个人想着一个人 提交于 2019-12-19 18:54:20
问题 i'm building a news section on my rails website and it uses will_paginate for pagination. now i was wondering how i can specify a custom offset for the first page with will_paginate. something like this: @featured_news = Post.first @news = Post.offset(1).paginate(:page => params[:page]) i need the latest news-entry to be special and not be included in the @news objects. how i can achieve this? thanks for your time! 回答1: will_paginate redefines every offset and limit query conditions, to get

Item's page and will_paginate

ぃ、小莉子 提交于 2019-12-19 06:14:13
问题 I have some photos that are split on successive pages through will_paginate plugin. When you open a photo and then return to all photos using a link, you always return to the first page (e.g. the photo is displayed on page 5, you open the photo, click a link to show all photos and expect that you are on page 5 again, but you are on page 1). Now, is there any method to get the page number to which a photo belongs to? I tried to pass a GET parameter, but this only works if the user doesn't

Infinite scroll and will_paginate appending the 'next page' of items multiple times

放肆的年华 提交于 2019-12-19 03:21:32
问题 I am following this railscast in trying to implement an infinite scroll page on my rails app. When a user scrolls down to the bottom of the page an new set of items is appended and the page extends, however it is appended to the page multiple times and the event triggers again on scrolldown even when all the items in the array have been loaded, appending the same set of items again multiple times. What I would like is to append the 'next page' of items each time a user scrolls to the bottom,