Skip to content

Instantly share code, notes, and snippets.

@tammersaleh
Forked from mtodd/account.rb
Created July 6, 2009 23:42
Show Gist options
  • Save tammersaleh/141767 to your computer and use it in GitHub Desktop.
Save tammersaleh/141767 to your computer and use it in GitHub Desktop.
class Account < ActiveRecord::Base
has_many :users
has_many :account_admin_permissions
end
@account.users.admins
Factory.define :account do |a|
a.name { Factory.next(:name) }
end
Factory.define :user do |u|
u.name { "%s User" % Factory.next(:name) }
u.login { |u| u.name.downcase.gsub(/\s/, '.') }
u.email { |u| "%s@example.com" % u.login }
u.password "secret"
u.password_confirmation { |u| u.password }
u.account { |u| u.association(:account) }
end
class User < ActiveRecord::Base
belongs_to :account
named_scope :admins, :conditions => {:admin => true}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment