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] before_action :set_card, only: [:show, :edit, :update, :destroy]
def index def index
@cards = Card.all @cards = Card.includes(:character).all
end end
def show def show
@ -42,7 +42,7 @@ class CardsController < ApplicationController
private private
def card_params 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, :leader_skill_id, :passive_skill_id,
:super_attack_id, :dokkan_id, :gameid, :super_attack_id, :dokkan_id, :gameid,
:awaken_type_id, :dokkan_id, link_ids: []) :awaken_type_id, :dokkan_id, link_ids: [])

View file

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

View file

@ -21,10 +21,10 @@
= f.association :passive_skill = f.association :passive_skill
.row .row
.col-md-6 .col-md-6
= f.association :super_attack = f.association :super_attack, label_method: :full
.row .row
.col-md-6 .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 .row
.col-md-12 .col-md-12
= f.label :links = f.label :links