Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 70 lines (57 sloc) 1.516 kB
0db652f @flyerhzm guard-annotate
flyerhzm authored
1 # == Schema Information
2 #
3 # Table name: jobs
4 #
5 # id :integer(4) not null, primary key
6 # title :string(255)
7 # description :text
8 # company :string(255)
9 # company_url :string(255)
10 # country :string(255)
11 # state :string(255)
12 # city :string(255)
13 # address :string(255)
14 # salary :string(255)
15 # apply_email :string(255)
16 # created_at :datetime
17 # updated_at :datetime
18 # user_id :integer(4)
19 # published :boolean(1)
20 # source :string(255)
21 # external_id :integer(4)
22 #
23
bdee07e @flyerhzm create a job, and show/index jobs
flyerhzm authored
24 class Job < ActiveRecord::Base
ccd8b61 @flyerhzm use model cache for job instead of caches_action
flyerhzm authored
25 include Cacheable
26
bdee07e @flyerhzm create a job, and show/index jobs
flyerhzm authored
27 has_many :job_job_types
28 has_many :job_types, :through => :job_job_types, :source => :job_type
ef315cc @flyerhzm job belongs_to user and add jobs rss
flyerhzm authored
29 belongs_to :user
bdee07e @flyerhzm create a job, and show/index jobs
flyerhzm authored
30
e3e286b @flyerhzm parse job data from rubyonjobs
flyerhzm authored
31 validates_presence_of :title, :company, :country, :city, :description, :apply_email
bdee07e @flyerhzm create a job, and show/index jobs
flyerhzm authored
32
476f7a0 @flyerhzm only display published jobs, email and tweet job
flyerhzm authored
33 scope :published, where(:published => true)
89b837c @flyerhzm only display jobs created in site for jobs partner
flyerhzm authored
34 scope :owner, where("source IS NULL")
476f7a0 @flyerhzm only display published jobs, email and tweet job
flyerhzm authored
35
36 after_create :notify_admin
37
ccd8b61 @flyerhzm use model cache for job instead of caches_action
flyerhzm authored
38 model_cache do
39 with_key
40 with_method :job_type_names
9afed50 @flyerhzm cache for Job#user
flyerhzm authored
41 with_association :user
ccd8b61 @flyerhzm use model cache for job instead of caches_action
flyerhzm authored
42 end
43
e2abac4 @flyerhzm fix display job type names for partner jobs
flyerhzm authored
44 def job_type_names
45 self.job_types.map(&:name)
89b837c @flyerhzm only display jobs created in site for jobs partner
flyerhzm authored
46 end
47
bdee07e @flyerhzm create a job, and show/index jobs
flyerhzm authored
48 def location
199cf7e @flyerhzm do not display empty state, city or country
flyerhzm authored
49 [self.state, self.city, self.country].compact.join(', ')
bdee07e @flyerhzm create a job, and show/index jobs
flyerhzm authored
50 end
476f7a0 @flyerhzm only display published jobs, email and tweet job
flyerhzm authored
51
52 def tweet_title
b8d366a @flyerhzm location of job includes the country
flyerhzm authored
53 "#{company} is looking for #{title} in #{location}"
476f7a0 @flyerhzm only display published jobs, email and tweet job
flyerhzm authored
54 end
55
56 def tweet_path
57 "jobs/#{to_param}"
58 end
59
60 def publish!
61 self.update_attribute(:published, true)
006ff0b @flyerhzm don't tweet when posting a job
flyerhzm authored
62 # Delayed::Job.enqueue(DelayedJob::Tweet.new('Job', self.id))
476f7a0 @flyerhzm only display published jobs, email and tweet job
flyerhzm authored
63 end
64
65 protected
66 def notify_admin
67 Delayed::Job.enqueue(DelayedJob::NotifyJob.new(self.id))
68 end
bdee07e @flyerhzm create a job, and show/index jobs
flyerhzm authored
69 end
Something went wrong with that request. Please try again.