Created
July 28, 2016 07:58
-
-
Save shaojunda/f14a080f055f4190663ebecdb1d52af9 to your computer and use it in GitHub Desktop.
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 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 |
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 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