1

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 the source of problem here? And how could I make it work?

1 Answer 1

1

With Kaminari, the error no longer exists and I got the feature what I wanted.

Diving deeper into the inner working of pg or will_paginate might find the cause of the problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.