add helper to show if a pet or mount is owned by the user
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module WowMountsHelper
|
||||
def mount_owned?(mount)
|
||||
mount.users.include? current_user
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module WowPetsHelper
|
||||
def pet_owned?(pet)
|
||||
pet.users.include? current_user
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,8 +4,8 @@ class WowPetAbility < ApplicationRecord
|
||||
extend Mobility
|
||||
translates :name, :translated_battle_pet_type
|
||||
|
||||
has_many :learned_pet_abilities, dependent: :destroy
|
||||
has_many :wow_pets, through: :learned_pet_abilities
|
||||
has_many :learned_wow_pet_abilities, dependent: :destroy
|
||||
has_many :wow_pets, through: :learned_wow_pet_abilities
|
||||
|
||||
validates :name, presence: true
|
||||
validates :ability_id, presence: true, uniqueness: true
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<h5 class="card-title"><%= @wow_character.title_name %></h5>
|
||||
<p class="card-text"><%= @wow_character.gender_race_name %></p>
|
||||
<p class="card-text"><%= @wow_character.gender_class_name %></p>
|
||||
<p class="card-text"><%= @wow_character.last_login_timestamp %></p>
|
||||
<p class="card-text">Last connection: <%= @wow_character.last_login_timestamp %></p>
|
||||
<p class="card-text">Last position: Map: <%= @wow_character.last_position.wow_geo_map.name %> Zone: <%= @wow_character.last_position.wow_geo_zone.name %></p>
|
||||
<p class="card-text">Bind position: Map: <%= @wow_character.bind_position.wow_geo_map.name %> Zone: <%= @wow_character.bind_position.wow_geo_zone.name %></p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><%= mount.name %></h5>
|
||||
<p class="card-text"><%= mount.description %></p>
|
||||
<p class="card-text">Owned: <%= mount_owned?(mount) %></p>
|
||||
<%= link_to 'Detail', mount, class: "btn btn-primary" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><%= pet.name %></h5>
|
||||
<p class="card-text"><%= pet.description %></p>
|
||||
<p class="card-text">Owned: <%= pet_owned?(pet) %></p>
|
||||
<%= link_to 'Detail', pet, class: "btn btn-primary" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user