Skip to content

Instantly share code, notes, and snippets.

Created October 4, 2010 23:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/610665 to your computer and use it in GitHub Desktop.
Save anonymous/610665 to your computer and use it in GitHub Desktop.
be careful with method empty?
class Cart < ActiveRecord::Base
has_many :line_items
delegate :empty?, :to => :line_items
end
class User < ActiveRecord::Base
has_one :cart
end
@user = User.new
@user.create_cart
@user.cart.present? # => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment