Merge branch 'atomaka/bugfix/card-order' into 'master'
Default scope sucks, fix ordering for cards `default_scope` is always active. It can be disabled by creating your ActiveRecord query with `unscoped` but that requires knowing about `default_scope`. Let's remove it and order per use case. See merge request !22
This commit is contained in:
commit
4555334d05
3 changed files with 3 additions and 3 deletions
|
@ -4,7 +4,7 @@ class Api::V1::CardsController < Api::V1::BaseController
|
||||||
@cards = Card.includes(:character, :rarity, :type, :leader_skill,
|
@cards = Card.includes(:character, :rarity, :type, :leader_skill,
|
||||||
:passive_skill, :super_attack, :awaken_type,
|
:passive_skill, :super_attack, :awaken_type,
|
||||||
:dokkan_card, :hp_stat, :atk_stat, :def_stat,
|
:dokkan_card, :hp_stat, :atk_stat, :def_stat,
|
||||||
:links)
|
:links).all.order(:gameid)
|
||||||
|
|
||||||
render json: @cards, root: false
|
render json: @cards, root: false
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,8 +35,6 @@ class Card < ActiveRecord::Base
|
||||||
validates :type, presence: true
|
validates :type, presence: true
|
||||||
validates :awaken_type, presence: true
|
validates :awaken_type, presence: true
|
||||||
|
|
||||||
default_scope { order(:gameid) }
|
|
||||||
|
|
||||||
scope :new_this_week, -> { where('created_at > ?', 1.week.ago) }
|
scope :new_this_week, -> { where('created_at > ?', 1.week.ago) }
|
||||||
|
|
||||||
def dokkan?
|
def dokkan?
|
||||||
|
|
|
@ -11,12 +11,14 @@
|
||||||
tr
|
tr
|
||||||
th Name
|
th Name
|
||||||
th Title
|
th Title
|
||||||
|
th Updated
|
||||||
th Actions
|
th Actions
|
||||||
tbody
|
tbody
|
||||||
- @cards.each do |card|
|
- @cards.each do |card|
|
||||||
tr
|
tr
|
||||||
td= card.name
|
td= card.name
|
||||||
td= card.title
|
td= card.title
|
||||||
|
td= card.updated_at
|
||||||
td
|
td
|
||||||
- if policy(:card).edit?
|
- if policy(:card).edit?
|
||||||
= link_to glyph('edit', classes: 'control-icon'), edit_admin_card_path(card)
|
= link_to glyph('edit', classes: 'control-icon'), edit_admin_card_path(card)
|
||||||
|
|
Loading…
Reference in a new issue