Cleanup a few N+1
This commit is contained in:
parent
5e458a3e48
commit
97ae2f33b2
3 changed files with 8 additions and 4 deletions
|
@ -2,7 +2,7 @@ class CardsController < ApplicationController
|
|||
before_action :set_card, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@cards = Card.all
|
||||
@cards = Card.includes(:character).all
|
||||
end
|
||||
|
||||
def show
|
||||
|
@ -42,7 +42,7 @@ class CardsController < ApplicationController
|
|||
private
|
||||
|
||||
def card_params
|
||||
params.require(:card).permit(:prefix, :character_id, :rarity_id, :type_id,
|
||||
params.require(:card).permit(:title, :character_id, :rarity_id, :type_id,
|
||||
:leader_skill_id, :passive_skill_id,
|
||||
:super_attack_id, :dokkan_id, :gameid,
|
||||
:awaken_type_id, :dokkan_id, link_ids: [])
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
class SuperAttack < ActiveRecord::Base
|
||||
validates :name, presence: true
|
||||
validates :description, presence: true
|
||||
|
||||
def full
|
||||
"#{name} - #{description}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
= f.association :passive_skill
|
||||
.row
|
||||
.col-md-6
|
||||
= f.association :super_attack
|
||||
= f.association :super_attack, label_method: :full
|
||||
.row
|
||||
.col-md-6
|
||||
= f.association :dokkan_card, label_method: :full_name
|
||||
= f.association :dokkan_card, collection: Card.includes(:character).all, label_method: :full_name
|
||||
.row
|
||||
.col-md-12
|
||||
= f.label :links
|
||||
|
|
Loading…
Reference in a new issue