Re: [Rails] Re: .empty? Method
by Brian V. Hughes other posts by this author
Feb 11 2006 6:14PM messages near this date
[Rails] Re: .empty? Method
|
[Rails] [ANN] form_remote_upload plugin
Michael Boutros wrote:
> def view
> @post = Posts.find(@params["id"])
> if @post.empty?
> render_text "Post does not exist."
> end
> end
You can't use empty? on a class object. That method isn't supported, which i
believe is exactly what the error message tried to tell you. You want to check
to see if the result of the find command has resulted in a defined @post object.
Change the condition to: if @post.nil?
or: unless @post
-Brian
_______________________________________________
Rails mailing list
Rails@[...].org
http://lists.rubyonrails.org/mailman/listinfo/rails
Thread:
Michael Boutros
Nick Stuart
Michael Boutros
Brian V. Hughes
|