1

以下应用程序与 sqlite 一起正常工作

图书模型

class Book < ActiveRecord::Base
    attr_accessible :month, :pages, :title, :year, :author_attributes, :publisher_attributes

    belongs_to :author
    belongs_to :publisher

    accepts_nested_attributes_for :author
    accepts_nested_attributes_for :publisher
end

图书控制器

class BooksController < ApplicationController
     respond_to(:html)

     expose(:books, :ancestor => [:author, :publisher]) { Book.scoped.paginate(:page => params[:page], :per_page=>params[:per_page])}
     expose(:book)
     # other functions here
end

使用postgresql,当我尝试访问时出现以下错误http://localhost:3000/books/1

ActiveRecord::StatementInvalid in Books#show

Showing /Users/tunwinnaing/Projects/rails_projects/books/app/views/books/show.html.haml where line #1 raised:

PG::UndefinedParameter: ERROR:  there is no parameter $1    
LINE 1: SELECT COUNT(*) FROM "books"  WHERE "books"."id" = $1    
                                                           ^
: SELECT COUNT(*) FROM "books"  WHERE "books"."id" = $1
Extracted source (around line #1):

1: - provide( :title, "#{book.title} | " )    
2: %h1= book.title    
3: %hr    
4: .row

背景资料

  • 红宝石 1.9.3
  • 导轨 3.2.13
  • 体面曝光 2.2.0
  • will_paginate 3.0.3
  • 第 0.16.0 页
  • postgresql 9.x(使用 postgresapp)

尝试了以下

这里问题的根源是什么?我怎样才能让它发挥作用?

4

1 回答 1

1

随着Kaminari,错误不再存在,我得到了我想要的功能。

深入研究内部工作pgwill_paginate可能找到问题的原因。

于 2013-08-31T18:43:54.927 回答