1
0
Fork 0
forked from OpenNeo/impress

only show item zones on outfits#edit occupies filter helper

This commit is contained in:
Emi Matchu 2013-02-05 11:52:52 -06:00
parent 5e37063674
commit e71530a958
2 changed files with 3 additions and 2 deletions

View file

@ -1,5 +1,5 @@
class ItemZoneSetsController < ApplicationController class ItemZoneSetsController < ApplicationController
def index def index
render :json => Zone.all_plain_labels render :json => Zone.for_items.all_plain_labels
end end
end end

View file

@ -13,13 +13,14 @@ class Zone < ActiveRecord::Base
t = Zone::Translation.arel_table t = Zone::Translation.arel_table
includes(:translations).where(t[:plain_label].eq(Zone.plainify_label(label))) includes(:translations).where(t[:plain_label].eq(Zone.plainify_label(label)))
} }
scope :for_items, lambda { where(arel_table[:type_id].gt(1)) }
def uncertain_label def uncertain_label
@sometimes ? "#{label} sometimes" : label @sometimes ? "#{label} sometimes" : label
end end
def self.all_plain_labels def self.all_plain_labels
Zone.select([:id]).includes(:translations).all.map(&:plain_label).uniq.sort select([:id]).includes(:translations).all.map(&:plain_label).uniq.sort
end end
def self.plainify_label(label) def self.plainify_label(label)