1
0
Fork 0

Cleanup a few N+1

This commit is contained in:
Andrew Tomaka 2015-10-08 13:02:25 -04:00
parent 5e458a3e48
commit 97ae2f33b2
3 changed files with 8 additions and 4 deletions

View file

@ -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: [])

View file

@ -1,4 +1,8 @@
class SuperAttack < ActiveRecord::Base
validates :name, presence: true
validates :description, presence: true
def full
"#{name} - #{description}"
end
end

View file

@ -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