Skip to content

Instantly share code, notes, and snippets.

@djsun
Created September 9, 2009 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djsun/184051 to your computer and use it in GitHub Desktop.
Save djsun/184051 to your computer and use it in GitHub Desktop.
class Comment < ActiveRecord::Base
belongs_to :post
end
test_proxy djsun$ script/console
Loading development environment (Rails 2.3.4)
>> c = Comment.new
=> #<Comment id: nil, body: nil, post_id: nil, created_at: nil, updated_at: nil>
>> c.post
=> nil
>> !c.post
=> true
>> c.post ? "t" : "f"
=> "f"
>> c.post.nil?
=> true
class Post < ActiveRecord::Base
has_many :comments
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment