views:

52

answers:

2
class Post < ActiveRecord::Base
end

post = Post.new

How do I judge whether the 'post' is a new model which is not pulled from the database?

+2  A: 
post.new_record?
Faisal
+10  A: 

ActiveRecord's new_record? method returns true if the object hasn't been saved yet.

John Topley