In ci_controller i wrote
def search_ci
page = (params[:page] ||= 1).to_i
software_cis_per_page = 3
offset = (page - 1) * software_cis_per_page
@software_cis = SoftwareCi.find_by_sql(["select * from software_cis
where name like ? and status like ? and citype like ? and ci_class like
?", "%" + params[:ci][:name] + "%", "%" +
params[:ci][:status] + "%",
"%" + params[:ci][:citype] + "%", "%" +
params[:ci][:ci_class] + "%" ])
@software_ci_pages = Paginator.new(self, @software_cis.length,
software_cis_per_page, page)
@software_cis = @software_cis[offset..(offset + software_cis_per_page -
1)]
end
and in the view search_ci.rhtml,
<%= link_to(''previous page'', {:params =>
params.merge(''page'' =>
@software_ci_pages.current.previous)}) if
@software_ci_pages.current.previous %>
<%= '' | '' if @software_ci_pages.current.previous and
@software_ci_pages.current.next %>
<%= link_to(''next page'', {:params =>
params.merge(''page'' =>
@software_ci_pages.current.next)}) if @software_ci_pages.current.next %>
The first page is displayed. But when we click on the ''next
page'' an
error occurs... "can''t convert nil into String"
I printed the value in ''page'' variable. It is 1 always.
any idea on how to fix this error.
--
Posted via http://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
-~----------~----~----~----~------~----~------~--~---
On 18 Dec 2007, at 09:15, Suneeta Km wrote:> and in the view search_ci.rhtml, > > <%= link_to(''previous page'', {:params => params.merge(''page'' => > @software_ci_pages.current.previous)}) if > @software_ci_pages.current.previous %> > <%= '' | '' if @software_ci_pages.current.previous and > @software_ci_pages.current.next %> > <%= link_to(''next page'', {:params => params.merge(''page'' => > @software_ci_pages.current.next)}) if > @software_ci_pages.current.next %> > > The first page is displayed. But when we click on the ''next page'' an > error occurs... "can''t convert nil into String" > > I printed the value in ''page'' variable. It is 1 always. >I rather suspect that you want link_to(''next page'', params.merge(''page'' => @software_ci_pages.current.next)) Looking at what rails thinks the params hash is should guide you on your way Fred> any idea on how to fix this error. > -- > Posted via http://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.g--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 18 Dec 2007, at 09:15, Suneeta Km wrote: >> >> The first page is displayed. But when we click on the ''next page'' an >> error occurs... "can''t convert nil into String" >> >> I printed the value in ''page'' variable. It is 1 always. >> > I rather suspect that you want link_to(''next page'', > params.merge(''page'' => @software_ci_pages.current.next)) > Looking at what rails thinks the params hash is should guide you on > your way > > Fred@software_cis has only the first 3 rows which is to be displayed in the first page. But i''m not able to display the remaining rows in the next page. Please suggest a solution to this. -- Posted via http://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 -~----------~----~----~----~------~----~------~--~---