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.