static public Method

Base.exists?(id, options = {})

Asserts the existence of a resource, returning true if the resource is found.

Examples

Note.create(:title => 'Hello, world.', :body => 'Nothing more for now...')
Note.exists?(1)
# => true

Note.exists(1349)
# => false

Source Code

# File active_resource/base.rb, line 439
def exists?(id, options = {})
  id && !find_single(id, options).nil?
rescue ActiveResource::ResourceNotFound
  false
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.