Sha256: c90d63e84bc8c0ccd149a5947ff2f5ddcad43aecbaf2dac8174eb238d518b554

Contents?: true

Size: 822 Bytes

Versions: 3

Compression:

Stored size: 822 Bytes

Contents

# == Schema Information
#
# Table name: jobs
#
#  id              :integer          not null, primary key
#  organization_id :integer
#  name            :string(255)
#  created_at      :datetime
#  updated_at      :datetime
#  color           :string(255)
#

class Job < ActiveRecord::Base
  after_commit :notify_users
  belongs_to :organization

  has_many :shifts

  has_and_belongs_to_many :users

  #validates_length_of :name, :within => 3..30
  #validates_uniqueness_of :name, :scope => :organization

  def notify_users
    Pusher.trigger(self.organization.name, 'jobchange', {:message => ''})
  end

  def self.employee_jobs users, org_id
    users = User.where(id: users).includes(:jobs)
  	jobs = {}
  	users.each do |user|
  		jobs[user.id] = user.jobs.where(:organization_id => org_id)
  	end
  	jobs
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pshq_engine-0.1.6 app/models/job.rb
pshq_engine-0.1.5 app/models/job.rb
pshq_engine-0.0.1 app/models/job.rb