Skip to content

Instantly share code, notes, and snippets.

@emilsoman
Created September 17, 2012 08:41
Show Gist options
  • Save emilsoman/3736217 to your computer and use it in GitHub Desktop.
Save emilsoman/3736217 to your computer and use it in GitHub Desktop.
class Search < ActiveRecord::Base
MAX_SAVED_SEARCHES_COUNT = 10
attr_accessible :keywords, :mocs, :last_activity_date, :source, :user_id
belongs_to :user
validates :user_id , presence: true
validate :saved_searches_count_check
private
def saved_searches_count_check
if current_user.searches.count > MAX_SAVED_SEARCHES_COUNT
#errors.add(:base,I18n.t(:)) unless user.has_role? :hem_employer
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment