public Method

Base.new?

A method to determine if the resource a new object (i.e., it has not been POSTed to the remote service yet).

Examples

not_new = Computer.create(:brand => 'Apple', :make => 'MacBook', :vendor => 'MacMall')
not_new.new?
# => false

is_new = Computer.new(:brand => 'IBM', :make => 'Thinkpad', :vendor => 'IBM')
is_new.new?
# => true

is_new.save
is_new.new?
# => false

Source Code

# File active_resource/base.rb, line 554
def new?
  id.nil?
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.