Afolabi Olaoluwa
Afolabi Olaoluwa

Reputation: 1948

How to post to multiple job boards from my job board - Ruby on Rails

What I like to do

I like to post job respectively to other free job boards upon checking a check_box when a job is created on my website.

Graphical explanation

This picture explains better what am hoping to achieve.

post on multiple job boards

What I think of doing

Thanks.

Upvotes: 0

Views: 210

Answers (1)

EdgeCaseLord
EdgeCaseLord

Reputation: 33

Just make a job scaffold like so (in the terminal):

rails new scaffold Jobs title description company logo location job_type remote:boolean url

and then use a gem like HTTParty to post the new jobs to the different APIs of the other job boards in the model after create. Like so:

# in app/models/jobs.rb
after_create_commit post_jobs_to_apis(job) 

def post_jobs_to_apis(job)
  url = [JOB_BOARD_URL] 
  api_key = [YOUR_JOB_BOARD_API_KEY] 
  
  headers = {
    :url = url, 
    :X-API-KEY: api_key
  } 
  
  body = job

  request = HTTParty.new(headers, body) 
  ... 
end

You have to look at the job boards' API documentation to find out how exactly to send data to these APIs, but usually you'd need an API-key, a URL to post to, and of course the contents you want to post.

Upvotes: 0

Related Questions