Skip to content

Instantly share code, notes, and snippets.

@joelbrewer
Created January 30, 2014 17:26
Show Gist options
  • Save joelbrewer/8713922 to your computer and use it in GitHub Desktop.
Save joelbrewer/8713922 to your computer and use it in GitHub Desktop.
project model
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