The following application working fine with sqlite.
Book model
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
Book controller
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
with postgresql, it gives the following error when I tried to visit 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
Background information
- ruby 1.9.3
- rails 3.2.13
- decent_exposure 2.2.0
- will_paginate 3.0.3
- pg 0.16.0
- postgresql 9.x (using postgresapp)
Tried the following
- What is causing PGError: ERROR: there is no parameter $1 in my Rails app - I need
will_paginateand couldn't remove the page - if I removed the
Book.scoped.paginatefromexpose(books), it works but I do not know how to paginate without scope. - I tried
prepared_statement: falseindatabase.ymland conclude that it has nothing to do with this error.
What is the source of problem here? And how could I make it work?