diff --git a/app/controllers/api/v1/jobs_controller.rb b/app/controllers/api/v1/jobs_controller.rb new file mode 100644 index 0000000..f79a40d --- /dev/null +++ b/app/controllers/api/v1/jobs_controller.rb @@ -0,0 +1,6 @@ +class Api::V1::JobsController < Api::V1::ApiController + def all + @jobs = Job.all() + render :all, status: :ok + end +end \ No newline at end of file diff --git a/app/models/job.rb b/app/models/job.rb index ddf6134..1263a02 100644 --- a/app/models/job.rb +++ b/app/models/job.rb @@ -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 diff --git a/app/views/api/v1/jobs/all.json.rabl b/app/views/api/v1/jobs/all.json.rabl new file mode 100644 index 0000000..f39bf78 --- /dev/null +++ b/app/views/api/v1/jobs/all.json.rabl @@ -0,0 +1,3 @@ +collection @jobs, object_root: false + +extends 'jobs/base' diff --git a/app/views/api/v1/jobs/base.json.rabl b/app/views/api/v1/jobs/base.json.rabl new file mode 100644 index 0000000..c806683 --- /dev/null +++ b/app/views/api/v1/jobs/base.json.rabl @@ -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 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 7c88858..8532969 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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'