Skip to content

Instantly share code, notes, and snippets.

@shaojunda
Last active July 27, 2016 07:41
Show Gist options
  • Save shaojunda/11a601f212368bac832eb6f45234397a to your computer and use it in GitHub Desktop.
Save shaojunda/11a601f212368bac832eb6f45234397a to your computer and use it in GitHub Desktop.
class AddMoreDetailToJob < ActiveRecord::Migration[5.0]
def change
add_column :jobs, :wage_upper_bound, :integer
add_column :jobs, :wage_lower_bound, :integer
add_column :jobs, :contact_email, :string
end
end
class Job < ApplicationRecord
belongs_to :user
validates :title, presence: true
validates :wage_upper_bound, presence: true
validates :wage_lower_bound, presence: true
validates :wage_lower_bound, numericality: {greater_than: 0}
scope :show_public, -> { where("is_hidden = 'false'") } # :is_hidden => false
scope :recent, -> { order(created_at: :desc) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment