Uh, @stories is going to be nil everytime - HTTP is stateless,
@stories is an instance variable the gets set every time the
controller is called. Why aren''t you just paginating directly from
the page number, and then just using -1/+1 values of the current page
for your links in the view?
On Oct 28, 9:14 pm, Chris Tosswill
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> I am a college student and just getting into the rails world. So please
> excuse me if the answer is simple... but I have RTFM and searched google
> many times to no avail.
>
> Alright I am making a simple blog like site. The site has two columns of
> content: stories and comic(images). Now I want each to have a pagination
> so you can click more_stories and it displays more stories but leaves
> the comics unchanged. Same if they hit "more_comics".
>
> I stated with the default pagination but quickly abandoned it in favor
> of will_paginate. The old pagination would advance both if you clicked
> either more.
>
> It seems that will_paginate should work as you can feed it the page
> number you want it to be on, but i have yet to get it to work.
>
> I use a link_to that just calls index and says if it was the story or
> image more that was clicked and if it was up or down.
>
> def index
>
> if @stories.nil?
> @p_image=1
> @p_story= 1
> @stories = Story.paginate :page => @p_story
> @images = Image.paginate :page => @p_image
> end
>
> if params[:type] == "story"
>
> if params[:call] == "up"
> @p_story = @p_story + 1
> end
>
> if params[:call] == "down"
> @p_story = @p_story - 1
> end
>
> @p_image = params[:iv]
> @stories = Story.paginate :page => @p_story
> end
>
> if params[:type] == "image"
>
> if params[:call] == "up"
> @p_image = @p_image + 1
> end
>
> if params[:call] == "down"
> @p_image = @p_image - 1
> end
>
> @p_story = params[ :sv ]
> @images = Image.paginate :page => @p_image
> end
> end
>
> Now i am clearly missing something as it wont go past a value of 2. and
> still resets when I switch between them.
>
> thank you in advance.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---