will-paginate

Getting will_paginate to reverse the per-page order

一世执手 提交于 2019-12-12 04:51:03
问题 I'm trying to get will_paginate to order my posts so that the newest post appears at the top of the first page but I can't seem to figure out how to get it to do that. This is the order when I sorty by ...order(:published_at) Page 1 2014-08-05 2014-08-04 2014-08-03 2014-08-02 2014-08-01 <- Oldest post Page 2 2014-08-10 <- Newest post 2014-08-09 2014-08-08 2014-08-07 2014-08-06 And this is what it does when I ...order("published_at DESC") it Page 1 2014-08-06 2014-08-07 2014-08-08 2014-08-09

Rails .page call on model also calls count

╄→尐↘猪︶ㄣ 提交于 2019-12-12 04:44:15
问题 Trying to do a simple Model.all.page(1) But whenever .page is called, it creates a SQL COUNT call. (My actual code is more complex than above, but simplified for ease of reading.) Is there a way to prevent .page from calling a SQL count? I'm dealing with millions of products and this calls is making the page refresh take an extra 2 seconds to load. I already have my own custom count which is instant so I don't need this .page count. Edit: Def not using .all. Bad example sorry. Heres a really

Rails Tutorial chapter 10.3.3 - 4 RSpec Errors (app working)

守給你的承諾、 提交于 2019-12-12 01:27:45
问题 I'm getting 4 RSpec errors that have something to do with the Will-Paginate gem, but for the life of me, I cant figure out what they're pointing at. The app works fine though. Failures: 1) UsersController GET 'index' for signed-in users should be successful Failure/Error: get :index NoMethodError: undefined method `paginate' for #<Class:0x9580710> # ./app/controllers/users_controller.rb:7:in `index' # ./spec/controllers/users_controller_spec.rb:30:in `block (4 levels) in <top (required)>' 2)

will_paginate JSON array

房东的猫 提交于 2019-12-11 23:45:03
问题 Decided to JSONify with Redis my site. How do I get will_paginate to work with json? # games.html.erb <%= js_will_paginate @games, renderer: BootstrapPagination::Rails, class: 'pagination-sm', previous_label: "←".html_safe, next_label: "→".html_safe, page_links: false %> This is the error I get: # undefined method `total_pages' for #<Array:0x007f90ebc05cf0> ln 23 of will_paginate_helper.rb ln23: will_paginate(collection, options.merge(:renderer => WillPaginateHelper:

JS controlling ajax tabs and JS controlling will_paginate in same js.erb not working (endless scroll)

余生颓废 提交于 2019-12-11 18:15:51
问题 I have tried to fix this for some time, but I cannot find the solution. I have ajax controlling some on page tabs, which is working fine: $("#feed-content").html("<%= escape_javascript(render(:partial => "#{@partial_name}")) %>"); But then I added will_paginate with endless scrolling, where I put the js that is controlling that in the same js.erb file as the above (sale.js.erb): $("#feed-content").html("<%= escape_javascript(render(:partial => "#{@partial_name}")) %>"); $('#products').append(

Mongoid is slow and shows this in the log: MONGODB cursor.refresh() for cursor 3474711247518436755

喜欢而已 提交于 2019-12-11 17:10:04
问题 I am using admin_assistant and have hacked on MongoDB support. The only issue now is that the index page queries are incredibly slow. admin_assistant uses will_paginate for these queries. I verified that the exact slow-down spot is where the will paginate collection is first accessed (.empty?). In the log I see the query, and after that I see these being slowly printed: MONGODB cursor.refresh() for cursor 3474711247518436755 MONGODB cursor.refresh() for cursor 3474711247518436755 MONGODB

rails 3 : will paginate creating incorrect links

故事扮演 提交于 2019-12-11 16:41:25
问题 This is my route match "/search/*keywords" => "public/search#index" ,:method=>:get, :as=>:search_with_keywords an example could be "/search/country-india/product_type-mobilephones" am using will paginate to create pagination links the */keywords is causing the following problem while creating the pagination link <%= will_paginate @results, :container => false, :class => 'pagination ajax' %> the generated link is "http://localhost:3000/search?keywords=country-india%2Fproduct_type-mobilephones

will_paginate function not rendering page links

天大地大妈咪最大 提交于 2019-12-11 13:11:32
问题 What I am trying to achieve is to paginate a huge number of rows (~8000). So I am using @extractedpacks = ExtractedPack.all.paginate :page => params[:page], :per_page=>20, :order => 'id DESC' To paginate in controller In the view index.html.erb <% @extractedpacks.each do |news| %> <tr> <td><%= news.name %></td> <td><%= news.acted_upon %></td> <td><%= news.crawl_category %></td> <td><%= link_to action_generator(news.crawl_category, news), @actionurl %></td> </tr> <% end %> </tbody> </table> <%

Rails will_paginate shows duplicates on HABTM models

半城伤御伤魂 提交于 2019-12-11 11:39:26
问题 I'm using will_paginate with a HABTM relationship between Blog Posts and Tags. Whenever I apply pagination, I get duplicate posts shown because the HABTM in Rails doesn't keep the database unique, it applies the uniqueness upon making the query. blog_posts.rb has_and_belongs_to_many :tags, :uniq => true tag.rb has_and_belongs_to_many :blog_posts, :uniq => true Per the documentation for ActiveRecord, :uniq does not prevent duplicate relationships being stored, it just ignores them when

RSpec test with factory_girl and will_paginate for associated objects

做~自己de王妃 提交于 2019-12-11 05:58:25
问题 I am having problems with writing a test in rspec for will_paginate. The problem is that I have a model with an Owner that can have many pets. This leads to a factories.rb file that looks like this: Factory.define :owner do |owner| owner.personid "1111111" owner.firstname "Nisse" owner.lastname "Gunnarsson" owner.street "Street" owner.postaladress "38830" owner.town "Town" owner.phone "555-5555" owner.mobile "555-5556" owner.email "nisse@test.com" owner.reminder true end Factory.define :pet