Skip to content

Instantly share code, notes, and snippets.

@shaojunda
Created July 28, 2016 07:58
Show Gist options
  • Save shaojunda/f14a080f055f4190663ebecdb1d52af9 to your computer and use it in GitHub Desktop.
Save shaojunda/f14a080f055f4190663ebecdb1d52af9 to your computer and use it in GitHub Desktop.
class Job < ApplicationRecord
belongs_to :user
validates :title, presence: true
validates :wage_upper_bound, presence: true, numericality: {greater_than: 0}
validates :wage_lower_bound, presence: true, numericality: {greater_than: 0}
# validates :wage_lower_bound, numericality: {greater_than: 0}
scope :show_public, -> { where("is_hidden = 'false'") } # :is_hidden => false
scope :recent, -> { order(created_at: :desc) }
def open!
self.is_hidden = false
self.save
end
def close!
self.is_hidden = true
self.save
end
end
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
has_many :jobs
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
def admin?
is_admin
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment