Compare commits
No commits in common. "8aa6eb40a702ab56e459182d9dd5f8d36b024d42" and "612cf914e0e65acd24212d7ead189758139af142" have entirely different histories.
8aa6eb40a7
...
612cf914e0
6 changed files with 80 additions and 36 deletions
|
@ -1,4 +1,5 @@
|
|||
class Color < ApplicationRecord
|
||||
translates # TODO: Remove once we're all done with translations!
|
||||
has_many :pet_types
|
||||
|
||||
scope :alphabetical, -> { order(:name) }
|
||||
|
@ -8,6 +9,16 @@ class Color < ApplicationRecord
|
|||
scope :funny, -> { order(:prank) unless pranks_funny? }
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
# Temporary writer to keep the English translation record updated, while
|
||||
# primarily using the attribute on the model itself.
|
||||
#
|
||||
# Once this app and DTI 2020 are both comfortably off the translation system,
|
||||
# we can remove this!
|
||||
def name=(new_name)
|
||||
globalize.write(:en, :name, new_name)
|
||||
write_attribute(:name, new_name)
|
||||
end
|
||||
|
||||
def as_json(options={})
|
||||
{id: id, name: name, human_name: human_name}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class Species < ApplicationRecord
|
||||
translates # TODO: Remove once we're all done with translations!
|
||||
has_many :pet_types
|
||||
has_many :alt_styles
|
||||
|
||||
|
@ -8,6 +9,16 @@ class Species < ApplicationRecord
|
|||
pt = PetType.arel_table
|
||||
joins(:pet_types).where(pt[:body_id].eq(body_id)).limit(1)
|
||||
}
|
||||
|
||||
# Temporary writer to keep the English translation record updated, while
|
||||
# primarily using the attribute on the model itself.
|
||||
#
|
||||
# Once this app and DTI 2020 are both comfortably off the translation system,
|
||||
# we can remove this!
|
||||
def name=(new_name)
|
||||
globalize.write(:en, :name, new_name)
|
||||
write_attribute(:name, new_name)
|
||||
end
|
||||
|
||||
def as_json(options={})
|
||||
super({only: [:id, :name], methods: [:human_name]}.merge(options))
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class Zone < ActiveRecord::Base
|
||||
class Zone < ActiveRecord::Base
|
||||
translates # TODO: Remove once we're all done with translations!
|
||||
|
||||
# When selecting zones that an asset occupies, we allow the zone to set
|
||||
# whether or not the zone is "sometimes" occupied. This is false by default.
|
||||
attr_writer :sometimes
|
||||
|
@ -9,6 +11,26 @@ class Zone < ActiveRecord::Base
|
|||
}
|
||||
scope :for_items, -> { where(arel_table[:type_id].gt(1)) }
|
||||
|
||||
# Temporary writer to keep the English translation record updated, while
|
||||
# primarily using the attribute on the model itself.
|
||||
#
|
||||
# Once this app and DTI 2020 are both comfortably off the translation system,
|
||||
# we can remove this!
|
||||
def label=(new_label)
|
||||
globalize.write(:en, :label, new_label)
|
||||
write_attribute(:label, new_label)
|
||||
end
|
||||
|
||||
# Temporary writer to keep the English translation record updated, while
|
||||
# primarily using the attribute on the model itself.
|
||||
#
|
||||
# Once this app and DTI 2020 are both comfortably off the translation system,
|
||||
# we can remove this!
|
||||
def plain_label=(new_plain_label)
|
||||
globalize.write(:en, :plain_label, new_plain_label)
|
||||
write_attribute(:plain_label, new_plain_label)
|
||||
end
|
||||
|
||||
def as_json(options={})
|
||||
super({only: [:id, :depth, :label]}.merge(options))
|
||||
end
|
||||
|
|
3
config/initializers/rack_mini_profiler.rb
Normal file
3
config/initializers/rack_mini_profiler.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
Rails.configuration.to_prepare do
|
||||
Rack::MiniProfiler.config.enable_advanced_debugging_tools = true
|
||||
end
|
|
@ -1,34 +0,0 @@
|
|||
class DropTranslationsForColorsAndSpeciesAndZones < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
drop_table "color_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.integer "color_id"
|
||||
t.string "locale"
|
||||
t.string "name"
|
||||
t.datetime "created_at", precision: nil
|
||||
t.datetime "updated_at", precision: nil
|
||||
t.index ["color_id"], name: "index_color_translations_on_color_id"
|
||||
t.index ["locale"], name: "index_color_translations_on_locale"
|
||||
end
|
||||
|
||||
drop_table "species_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.integer "species_id"
|
||||
t.string "locale"
|
||||
t.string "name"
|
||||
t.datetime "created_at", precision: nil
|
||||
t.datetime "updated_at", precision: nil
|
||||
t.index ["locale"], name: "index_species_translations_on_locale"
|
||||
t.index ["species_id"], name: "index_species_translations_on_species_id"
|
||||
end
|
||||
|
||||
drop_table "zone_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.integer "zone_id"
|
||||
t.string "locale"
|
||||
t.string "label"
|
||||
t.string "plain_label"
|
||||
t.datetime "created_at", precision: nil
|
||||
t.datetime "updated_at", precision: nil
|
||||
t.index ["locale"], name: "index_zone_translations_on_locale"
|
||||
t.index ["zone_id"], name: "index_zone_translations_on_zone_id"
|
||||
end
|
||||
end
|
||||
end
|
33
db/schema.rb
33
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_02_03_161355) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_02_01_134440) do
|
||||
create_table "alt_styles", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
|
||||
t.integer "species_id", null: false
|
||||
t.integer "color_id", null: false
|
||||
|
@ -70,6 +70,16 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_03_161355) do
|
|||
t.index ["user_id"], name: "index_closet_lists_on_user_id"
|
||||
end
|
||||
|
||||
create_table "color_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.integer "color_id"
|
||||
t.string "locale"
|
||||
t.string "name"
|
||||
t.datetime "created_at", precision: nil
|
||||
t.datetime "updated_at", precision: nil
|
||||
t.index ["color_id"], name: "index_color_translations_on_color_id"
|
||||
t.index ["locale"], name: "index_color_translations_on_locale"
|
||||
end
|
||||
|
||||
create_table "colors", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.boolean "basic"
|
||||
t.boolean "standard"
|
||||
|
@ -239,6 +249,16 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_03_161355) do
|
|||
t.string "name", null: false
|
||||
end
|
||||
|
||||
create_table "species_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.integer "species_id"
|
||||
t.string "locale"
|
||||
t.string "name"
|
||||
t.datetime "created_at", precision: nil
|
||||
t.datetime "updated_at", precision: nil
|
||||
t.index ["locale"], name: "index_species_translations_on_locale"
|
||||
t.index ["species_id"], name: "index_species_translations_on_species_id"
|
||||
end
|
||||
|
||||
create_table "swf_assets", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t|
|
||||
t.string "type", limit: 7, null: false
|
||||
t.integer "remote_id", limit: 3, null: false
|
||||
|
@ -276,6 +296,17 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_03_161355) do
|
|||
t.boolean "support_staff", default: false, null: false
|
||||
end
|
||||
|
||||
create_table "zone_translations", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.integer "zone_id"
|
||||
t.string "locale"
|
||||
t.string "label"
|
||||
t.string "plain_label"
|
||||
t.datetime "created_at", precision: nil
|
||||
t.datetime "updated_at", precision: nil
|
||||
t.index ["locale"], name: "index_zone_translations_on_locale"
|
||||
t.index ["zone_id"], name: "index_zone_translations_on_zone_id"
|
||||
end
|
||||
|
||||
create_table "zones", id: :integer, charset: "latin1", collation: "latin1_swedish_ci", force: :cascade do |t|
|
||||
t.integer "depth"
|
||||
t.integer "type_id"
|
||||
|
|
Loading…
Reference in a new issue