From 9e51fa7d34e55d16b8ee536067e5143901847f97 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Wed, 14 Jan 2026 01:22:58 +0900 Subject: [PATCH] =?UTF-8?q?#215=20=E3=83=86=E3=82=B9=E3=83=88=E3=83=BB?= =?UTF-8?q?=E3=82=B1=E3=83=BC=E3=82=B9=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/controllers/tags_controller.rb | 6 +++++- backend/config/application.rb | 1 + backend/config/locales/ja.yml | 2 ++ backend/spec/factories/wiki_pages.rb | 7 +++++++ backend/spec/rails_helper.rb | 4 ++++ 5 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 backend/config/locales/ja.yml create mode 100644 backend/spec/factories/wiki_pages.rb diff --git a/backend/app/controllers/tags_controller.rb b/backend/app/controllers/tags_controller.rb index ffa3527..baf0e7e 100644 --- a/backend/app/controllers/tags_controller.rb +++ b/backend/app/controllers/tags_controller.rb @@ -26,7 +26,11 @@ class TagsController < ApplicationController def show tag = Tag.find_by(id: params[:id]) - render json: tag.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki]) + if tag + render json: tag.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki]) + else + head :not_found + end end def show_by_name diff --git a/backend/config/application.rb b/backend/config/application.rb index 14b74b9..24390bd 100644 --- a/backend/config/application.rb +++ b/backend/config/application.rb @@ -11,6 +11,7 @@ module Backend # Initialize configuration defaults for originally generated Rails version. config.load_defaults 8.0 + config.i18n.available_locales = [:ja, :en] config.i18n.default_locale = :ja # Please, add to the `ignore` list any other `lib` subdirectories that do diff --git a/backend/config/locales/ja.yml b/backend/config/locales/ja.yml new file mode 100644 index 0000000..47cf834 --- /dev/null +++ b/backend/config/locales/ja.yml @@ -0,0 +1,2 @@ +ja: + hello: 'ぬ゛〜゛ん゛' diff --git a/backend/spec/factories/wiki_pages.rb b/backend/spec/factories/wiki_pages.rb new file mode 100644 index 0000000..b4f1496 --- /dev/null +++ b/backend/spec/factories/wiki_pages.rb @@ -0,0 +1,7 @@ +FactoryBot.define do + factory :wiki_page do + title { "TestPage" } + association :created_user, factory: :user + association :updated_user, factory: :user + end +end diff --git a/backend/spec/rails_helper.rb b/backend/spec/rails_helper.rb index 22122cb..480f4cb 100644 --- a/backend/spec/rails_helper.rb +++ b/backend/spec/rails_helper.rb @@ -39,6 +39,10 @@ rescue ActiveRecord::PendingMigrationError => e abort e.to_s.strip end RSpec.configure do |config| + config.before do + I18n.locale = :en + end + config.include TestRecords # FactoryBot の create / create_list を使へるやぅにする