Will_paginate problem

Hi,everybody
I write a code like follow,the question was “paginate” has been drop
until the rails 2.0,now we use
“will_paginate” to replace it.But I don’t know how to change my code
to let it suitable.

def index
@page_title = “Book List”
@book_pages,@books = Book.paginate :books,
:per_page => 10,
:include =>
[:authors, :publishers],
:order => “books.id
desc”

So,I want may be somebody can help .

Hi,Dhruva
Thank you for your help,but I still can’t pass my test.May be the code
goes wrong .

On Wed, Sep 2, 2009 at 10:23 AM, Dhruva S.
[email protected]wrote:

Thanks & Regards,

until the rails 2.0,now we use
:order => “books.id
desc”


So,I want may be somebody can help .


Sons of Gondor, of Rohan, my brothers!
I see in your eyes the same fear that would take the heart of me.
A day may come when the courage of men fails when we forsake our friends
and
break all bonds of fellowship.
But this is not this day.
And hour of wolves and shattered shields when the age of Men comes
crashing
down. But this is not this day!
This day we fight! By all that you hold dear on this good earth, I bid
you
stand! Men of the West!

The will_paginate’s paginate method creates both the instance variables
and
maintains them automatically.
All you will need to do is :

@books = Book.paginage :page => parmas[:page], :per_page => 10, :include
=>
[:authors, :publishers], :order => :id

You should check out railscasts.com episode 51, it demonstrates what you
wish to do quite well.

Thanks & Regards,
Dhruva S…

Ted Turner http://www.brainyquote.com/quotes/authors/t/ted_turner.html

“Sports is like a war without the killing.”

try params[:page] instead of parmas[:page]
Also if you have an error post the trace here
if we cant see the error … we cant see the problem

Oh, thanks for pointing that out Adam,
There is indeed a spellings mistake, it must be params[:page]

Thanks & Regards,
Dhruva S…

Marie von
Ebner-Eschenbachhttp://www.brainyquote.com/quotes/authors/m/marie_von_ebnereschenbac.html

  • “Even a stopped clock is right twice a day.”

One thing that I forgot is that you will need to add the following to
your
view to create the page links

<%= will_paginate @books %>

Thanks & Regards,
Dhruva S…

Stephen
Leacockhttp://www.brainyquote.com/quotes/authors/s/stephen_leacock.html

  • “I detest life-insurance agents: they always argue that I shall some
    day
    die, which is not so.”

Ok it seems in a hurry to type I have made quite a few spelling
mistakes, I
will write it again (carefully) now, this is what you should have :

@books = Book.paginate :page => params[:page], :per_page => 10, :include
=>
[:authors, :publishers], :order => :id

and in the view for the page links you will need :

<%= will_paginate @books %>

Please try the one I have mentioned above, this should work properly
earlier
I had misspelled paginate to paginage :-S. Sorry for those typos.

Thanks & Regards,
Dhruva S…

Mike Ditka http://www.brainyquote.com/quotes/authors/m/mike_ditka.html

“If God had wanted man to play soccer, he wouldn’t have given us arms.”

It still goes wrong,

First,I want say sorry to Dhruva,because i didn’t write a test,it was a
controller.When I run my
Webrick and try to use controller like
http://localhost:3000/catalog/index
it goes wrong,like this—>

C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1532:in
method_missing_without_paginate' C:/Ruby/lib/ruby/gems/1.8/gems/mislav-will_paginate-2.3.11/lib/will_paginate/finder.rb:170:in method_missing’

app/controllers/catalog_controller.rb:5:in `index’

So,what i do for thoes code

On Wed, Sep 2, 2009 at 10:43 AM, Adam [email protected] wrote:

goes wrong .

You should check out railscasts.com episode 51, it demonstrates what you

                                              :per_page => 10,

And hour of wolves and shattered shields when the age of Men comes crashing


Sons of Gondor, of Rohan, my brothers!
I see in your eyes the same fear that would take the heart of me.
A day may come when the courage of men fails when we forsake our friends
and
break all bonds of fellowship.
But this is not this day.
And hour of wolves and shattered shields when the age of Men comes
crashing
down. But this is not this day!
This day we fight! By all that you hold dear on this good earth, I bid
you
stand! Men of the West!

When i change ‘publishers’ to ‘publisher’,now we got like follow

private method `scan’ called for :id:Symbol

On Wed, Sep 2, 2009 at 11:27 AM, fireflyman [email protected]
wrote:

Thanks & Regards,

http://localhost:3000/catalog/index

All you will need to do is :


Sons of Gondor, of Rohan, my brothers!

I see in your eyes the same fear that would take the heart of me.

and break all bonds of fellowship.
But this is not this day.
And hour of wolves and shattered shields when the age of Men comes crashing
down. But this is not this day!
This day we fight! By all that you hold dear on this good earth, I bid you
stand! Men of the West!


Sons of Gondor, of Rohan, my brothers!
I see in your eyes the same fear that would take the heart of me.
A day may come when the courage of men fails when we forsake our friends
and
break all bonds of fellowship.
But this is not this day.
And hour of wolves and shattered shields when the age of Men comes
crashing
down. But this is not this day!
This day we fight! By all that you hold dear on this good earth, I bid
you
stand! Men of the West!

In the statement, it should be :order => ‘id’ and not :order => :id

Thanks & Regards,
Dhruva S…

Marie von
Ebner-Eschenbachhttp://www.brainyquote.com/quotes/authors/m/marie_von_ebnereschenbac.html

  • “Even a stopped clock is right twice a day.”

We had got another failure–>

private method `scan’ called for 48756360:Fixnum

On Wed, Sep 2, 2009 at 11:42 AM, Dhruva S.
[email protected]wrote:

When i change ‘publishers’ to ‘publisher’,now we got like follow

C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1532:in `method_missing_without_paginate’

variables and maintains them automatically.

to let it suitable.
desc"

I see in your eyes the same fear that would take the heart of me.

stand! Men of the West!


Sons of Gondor, of Rohan, my brothers!
I see in your eyes the same fear that would take the heart of me.
A day may come when the courage of men fails when we forsake our friends
and
break all bonds of fellowship.
But this is not this day.
And hour of wolves and shattered shields when the age of Men comes
crashing
down. But this is not this day!
This day we fight! By all that you hold dear on this good earth, I bid
you
stand! Men of the West!

Now,we got a new problem,like this–>

Association named ‘publishers’ was not found; perhaps you misspelled it?

On Wed, Sep 2, 2009 at 11:15 AM, Dhruva S.
[email protected]wrote:

Please try the one I have mentioned above, this should work properly

First,I want say sorry to Dhruva,because i didn’t write a test,it was a

The will_paginate’s paginate method creates both the instance variables
Dhruva S…

“will_paginate” to replace it.But I don’t know how to change my code
desc"


Sons of Gondor, of Rohan, my brothers!
I see in your eyes the same fear that would take the heart of me.
A day may come when the courage of men fails when we forsake our friends
and
break all bonds of fellowship.
But this is not this day.
And hour of wolves and shattered shields when the age of Men comes
crashing
down. But this is not this day!
This day we fight! By all that you hold dear on this good earth, I bid
you
stand! Men of the West!

Hi,DhruvaI had success with my code.Here is the code. controller code–>

def index

@page_title = "Book List"
@books = Book.paginate :page => params[:page],
                        :per_page => 10,
                        :include => [:authors, :publisher],
                         :order => "books.id desc"

end

view code →

<%= will_paginate @books ,
:inner_window => 1,
:outer_window => 1,
:prev_label => ‘Previous’,
:next_label => ‘Next’
%>

On Wed, Sep 2, 2009 at 11:49 AM, fireflyman [email protected]
wrote:

private method `scan’ called for :id:Symbol

On 2/09/2009, at 2:40 PM, fireflyman wrote:

All you will need to do is :

“will_paginate” to replace it.But I don’t know how to change my
:order => "

This day we fight! By all that you hold dear on this good earth, I

you stand! Men of the West!

crashing down. But this is not this day!

stand! Men of the West!


Sons of Gondor, of Rohan, my brothers!
I see in your eyes the same fear that would take the heart of me.
A day may come when the courage of men fails when we forsake our friends
and
break all bonds of fellowship.
But this is not this day.
And hour of wolves and shattered shields when the age of Men comes
crashing
down. But this is not this day!
This day we fight! By all that you hold dear on this good earth, I bid
you
stand! Men of the West!

Your welcome, glad it helped :).
Thanks & Regards,
Dhruva S…

Charles de
Gaullehttp://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html

  • “The better I get to know men, the more I find myself loving dogs.”

Thanks a lot !You are good man.

On Wed, Sep 2, 2009 at 12:06 PM, fireflyman [email protected]
wrote:

view code →

<% end %>

On Wed, Sep 2, 2009 at 8:59 AM, fireflyman [email protected]wrote:

@books = Book.paginate :page => params[:page], :per_page => 10,
Dhruva S…

it goes wrong,like this—>

post the trace here
On Wed, Sep 2, 2009 at 10:23 AM, Dhruva S. <

what you wish to do quite well.

@page_title = “Book List”

A day may come when the courage of men fails when we forsake our

friends and break all bonds of fellowship.

And hour of wolves and shattered shields when the age of Men comes
I see in your eyes the same fear that would take the heart of me.

and break all bonds of fellowship.


Sons of Gondor, of Rohan, my brothers!
I see in your eyes the same fear that would take the heart of me.
A day may come when the courage of men fails when we forsake our friends
and
break all bonds of fellowship.
But this is not this day.
And hour of wolves and shattered shields when the age of Men comes
crashing
down. But this is not this day!
This day we fight! By all that you hold dear on this good earth, I bid
you
stand! Men of the West!