Created
September 5, 2013 10:18
-
-
Save pschyska/6448376 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TierMembership < ActiveRecord::Base | |
attr_accessible :tier, :user | |
belongs_to :tier | |
belongs_to :user | |
validates :user_id, presence: true | |
validates :tier_id, presence: true, uniqueness: { scope: :user_id } | |
validate :valid_user_role | |
def valid_user_role | |
unless user.blank? || ["agent", "admin"].include?(user.account.role) | |
errors.add(:user, "must be agent or admin") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment