I use will_paginate to get results:
@results = Users.paginate(:all, :conditions => "…
But how can I get a number of reults?
I use will_paginate to get results:
@results = Users.paginate(:all, :conditions => "…
But how can I get a number of reults?
How can I write it simple?
if @results.empty?
x = 0
else
x = 1
end
x = @results.empty? ? 1 : 0
Ryan B.
Freelancer
And instead of empty, you should use “blank?”, that would work even if
@results is “nil”
x = @results.blank? ? 1 : 0
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
James B. wrote:
I use will_paginate to get results:
@results = Users.paginate(:all, :conditions => "…
But how can I get a number of reults?
to get a number of result you can get it by :
@results.size
if @results.size < 1
flash[:notice] = “There’s no result so its data is empty.”
end
On Wed, Jan 14, 2009 at 3:24 AM, Rails T. <
[email protected]> wrote:
@results.size
@results.size will give you the number in that ‘page’
@results.total_entries will give you the total number of results you’re
paginating over
–
Andrew T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake
“I have never let my schooling interfere with my education” - Mark Twain
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs