How to get parameters of page in view

Hi all,

I have to put serial numbers but in pagination. If in my coding i put
loop like
<% i=1
@products.each do |product|
i = i+1
%>

serial number <%= i %> ....... It displays number from 1 to 9 but when i go to second page it again displays numbers from 1 to so..... on. I need serial numbers 1 to so on..... on all the pages.

Any help would be greatly appreciated.

Thanks,
Rucihta.

Check out this post…

http://www.railsforum.com/viewtopic.php?pid=490

Ratnavel S. wrote:

Check out this post…

http://www.railsforum.com/viewtopic.php?pid=490

Yeah… I have checked this link. But this doesn’t fulfill my
requirement.
I want the serial numbers against my products but they are not coming
correct on the second page.

On 26 Dec 2007, at 07:56, Ruchita S. wrote:

serial number <%= i %> ....... It displays number from 1 to 9 but when i go to second page it again displays numbers from 1 to so..... on. I need serial numbers 1 to so on..... on all the pages.

Surely a product’s serial number should be an attribute of product and
not something you’ve conjured up in the view?
That said if pages is your paginator, something like
pages.current_page.offset tells you how many have been skipped.

Fred

Frederick C. wrote:

On 26 Dec 2007, at 07:56, Ruchita S. wrote:

serial number <%= i %> ....... It displays number from 1 to 9 but when i go to second page it again displays numbers from 1 to so..... on. I need serial numbers 1 to so on..... on all the pages.

Surely a product’s serial number should be an attribute of product and
not something you’ve conjured up in the view?
That said if pages is your paginator, something like
pages.current_page.offset tells you how many have been skipped.

Fred

Hi,

Product serial number is not in products table. In products table i have
an id which is auto incremented, but i need a serial number in the view
to display how many products have been added. If i take product id and
display it then it won’t serve the purpose because it is auto
incremented and if i delete the products it wont display correct serial
numbers.

Thanks,
Ruchita.

Hi,

I want product serial number in my view.
If i put the code
<% 1 = 1
@products.each do |product| %>
<% i=i+1%>

serial number <%= i %>

It displays number from 1 to 9 but when i go to second page it again
displays numbers from 1 to 9 .
I need serial numbers 1 to so on… on all the pages.

Any help would be greatly appreciated.

Thanks,
Ruchita.

Hi,
Am writing this code to get serial numbers along with the products…
On each page 5 products are displayed.
<% 1 = 1
@products.each do |product| %>
<% i=i+1%>

<% if @product_pages.page_count > 1 %>
<%= i+5%>
<% else %>
<% i %>
<% end %>
But its is displaying serial numbers like 6,7,8,9,10 and again 6,7…

Its not working. Please tell me some other option.

Hi,

Can you use i = product_pages.page_count* 5 + i, maybe that will help.

atul

On 12/28/07, Ruchita S. [email protected] wrote:

Its not working. Please tell me some other option.

One option you might consider is to provide some context. Not
everyone here reads the web forum, so we have no clue what exactly is
not working for you.


Greg D.
http://destiney.com/