Export job skills in template

This commit is contained in:
Justin Edmund 2022-12-01 04:46:44 -08:00
parent 8e5571265f
commit 1ba16a2c61
2 changed files with 69 additions and 32 deletions

View file

@ -1,28 +1,49 @@
class Party < ApplicationRecord class Party < ApplicationRecord
##### ActiveRecord Associations ##### ActiveRecord Associations
belongs_to :user, optional: true belongs_to :user, optional: true
belongs_to :raid, optional: true belongs_to :raid, optional: true
belongs_to :job, optional: true belongs_to :job, optional: true
has_many :characters,
foreign_key: "party_id",
class_name: "GridCharacter",
dependent: :destroy
has_many :weapons, belongs_to :skill0,
foreign_key: "party_id", foreign_key: "skill0_id",
class_name: "GridWeapon", class_name: "JobSkill",
dependent: :destroy optional: true
has_many :summons, belongs_to :skill1,
foreign_key: "party_id", foreign_key: "skill1_id",
class_name: "GridSummon", class_name: "JobSkill",
dependent: :destroy optional: true
has_many :favorites
attr_accessor :favorited
def is_favorited(user) belongs_to :skill2,
user.favorite_parties.include? self foreign_key: "skill2_id",
end class_name: "JobSkill",
end optional: true
belongs_to :skill3,
foreign_key: "skill3_id",
class_name: "JobSkill",
optional: true
has_many :characters,
foreign_key: "party_id",
class_name: "GridCharacter",
dependent: :destroy
has_many :weapons,
foreign_key: "party_id",
class_name: "GridWeapon",
dependent: :destroy
has_many :summons,
foreign_key: "party_id",
class_name: "GridSummon",
dependent: :destroy
has_many :favorites
attr_accessor :favorited
def is_favorited(user)
user.favorite_parties.include? self
end
end

View file

@ -1,31 +1,47 @@
object :party object :party
attributes :id, :name, :description, :element, :favorited, :shortcode, :created_at, :updated_at attributes :id,
:name,
:description,
:element,
:favorited,
:shortcode,
:created_at,
:updated_at
node :extra do |p| node :extra do |p|
p.extra p.extra
end end
node :user do |p| node :user do |p|
partial('users/base', :object => p.user) partial("users/base", object: p.user)
end end
node :raid do |p| node :raid do |p|
partial('raids/base', :object => p.raid) partial("raids/base", object: p.raid)
end end
node :job do |p| node :job do |p|
partial('jobs/base', :object => p.job) partial("jobs/base", object: p.job)
end
node :job_skills do |p|
{
"0" => partial("job_skills/base", object: p.skill0),
"1" => partial("job_skills/base", object: p.skill1),
"2" => partial("job_skills/base", object: p.skill2),
"3" => partial("job_skills/base", object: p.skill3),
}
end end
node :characters do |p| node :characters do |p|
partial('grid_characters/base', :object => p.characters) partial("grid_characters/base", object: p.characters)
end end
node :weapons do |p| node :weapons do |p|
partial('grid_weapons/base', :object => p.weapons) partial("grid_weapons/base", object: p.weapons)
end end
node :summons do |p| node :summons do |p|
partial('grid_summons/base', :object => p.summons) partial("grid_summons/base", object: p.summons)
end end