public Method

Base.exists?

Evaluates to true if this resource is not +new?+ and is found on the remote service. Using this method, you can check for resources that may have been deleted between the object’s instantiation and actions on it.

Examples

Person.create(:name => 'Theodore Roosevelt')
that_guy = Person.find(:first)
that_guy.exists?
# => true

that_lady = Person.new(:name => 'Paul Bean')
that_lady.exists?
# => false

guys_id = that_guy.id
Person.delete(guys_id)
that_guy.exists?
# => false

Source Code

# File active_resource/base.rb, line 692
def exists?
  !new? && self.class.exists?(id, :params => prefix_options)
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.