Skip to content

Instantly share code, notes, and snippets.

@rbarazi
Created March 9, 2010 03:38
Show Gist options
  • Save rbarazi/326128 to your computer and use it in GitHub Desktop.
Save rbarazi/326128 to your computer and use it in GitHub Desktop.
[Beginning Rails 3] Listing 5-24. validates :uniqueness => true method, in app/models/user.rb
class User < ActiveRecord::Base
validates :email, :uniqueness => true
has_one :profile
has_many :articles, :order => 'published_at DESC, title ASC',
:dependent => :nullify
has_many :replies, :through => :articles, :source => :comments
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment