Add endpoint for fetching all jobs

This commit is contained in:
Justin Edmund 2022-03-22 03:41:00 -07:00
parent 1eec816111
commit c3566944cd
5 changed files with 30 additions and 3 deletions

View file

@ -0,0 +1,6 @@
class Api::V1::JobsController < Api::V1::ApiController
def all
@jobs = Job.all()
render :all, status: :ok
end
end

View file

@ -1,7 +1,7 @@
class Job < ApplicationRecord
belongs_to :party
def display_resource(class)
class.name_en
def display_resource(job)
job.name_en
end
end

View file

@ -0,0 +1,3 @@
collection @jobs, object_root: false
extends 'jobs/base'

View file

@ -0,0 +1,17 @@
object :job
attributes :id, :row, :ml, :order
node :name do |j|
{
:en => j.name_en,
:ja => j.name_jp
}
end
node :proficiency do |j|
[
j.proficiency1,
j.proficiency2
]
end

View file

@ -26,6 +26,7 @@ Rails.application.routes.draw do
post 'search/weapons', to: 'search#weapons'
post 'search/summons', to: 'search#summons'
get 'jobs', to: 'jobs#all'
get 'raids', to: 'raids#all'
get 'weapon_keys', to: 'weapon_keys#all'