Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 31st, 2012  |  syntax: Rails  |  size: 0.50 KB  |  views: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class User < ActiveRecord::Base
  2.   devise :database_authenticatable, :registerable,
  3.          :recoverable, :rememberable, :trackable, :validatable
  4.  
  5.   attr_accessible :email, :password, :password_confirmation, :remember_me, :name
  6.   default_scope :order => 'name ASC'
  7.  
  8.   has_many :tournaments
  9.   has_many :memberships
  10.   has_many :clubs, :through => :memberships
  11.  
  12.   def organises(tournament)
  13.     tournament.user.clubs.each do |club|
  14.       return true if club.owner == self
  15.     end
  16.     false
  17.   end
  18. end
clone this paste RAW Paste Data