Created
January 30, 2014 17:26
-
-
Save joelbrewer/8713922 to your computer and use it in GitHub Desktop.
project model
This file contains 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 Project < ActiveRecord::Base | |
belongs_to :user | |
validates :user_id, presence: true | |
validate :project_count_within_limit, :on => :create | |
validates :title, | |
:contact_name, | |
:email_address, | |
:phone_number, | |
:description, | |
:category, | |
:sub_category, | |
:presence => true | |
def project_count_within_limit | |
#if self.user.projects(:reload).count >= self.user.subscription.plan.user_project_limit | |
# errors.add(:base, "You can only create #{self.user.subscription.plan.user_project_limit} project(s) with your current plan.") | |
#end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment