ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-rails
ruby-rails
Re: [Rails] .empty? Method
by Nick Stuart other posts by this author
Feb 11 2006 5:46PM messages near this date
[Rails] .empty? Method | [Rails] Re: .empty? Method
It looks like you are calling it on a Post object, where the .empty is
meant for collections/strings and such. Should the above line read,
if @posts.empty?
..

Notice the s. I'm guessing you are loading posts like:
@posts = Post.find(:all)?

if so then @posts.empty? should work just fine.

-Nick

On 2/11/06, Michael Boutros <me@[...].com>  wrote:
>  I am using:
> 
>      if @post.empty?
>         render_text "Post does not exist."
>      end
> 
>  But it gives me this error:
> 
>  NoMethodError in Posts#view
> 
>  undefined method `empty?' for #<Posts:0x39598d0>
> 
>  However, if the method list empty? apears and stuff so I am confused.
> 
>  --
>  Posted via http://www.ruby-forum.com/.
>  _______________________________________________
>  Rails mailing list
>  Rails@[...].org
>  http://lists.rubyonrails.org/mailman/listinfo/rails
> 
_______________________________________________
Rails mailing list
Rails@[...].org
http://lists.rubyonrails.org/mailman/listinfo/rails
Thread:
Michael Boutros
Nick Stuart
Michael Boutros
Brian V. Hughes

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved