feat: オリジナルの作成日時追加( #101 ) (#117)

#101 オリジナルの作成日時(より前)の自動設定

#101 余白追加

#101 余白追加

#101 オリジナルの作成日時,フォームにフィールド追加

#101 マイグレとコントローラ

Co-authored-by: miteruzo <miteruzo@naver.com>
Reviewed-on: #117
このコミットはPull リクエスト #117 でマージされました.
このコミットが含まれているのは:
2025-09-22 05:05:30 +09:00
コミット 6bca0215d8
9個のファイルの変更194行の追加28行の削除
+18
ファイルの表示
@@ -15,6 +15,8 @@ class Post < ApplicationRecord
foreign_key: :target_post_id
has_one_attached :thumbnail
validate :validate_original_created_range
def as_json options = { }
super(options).merge({ thumbnail: thumbnail.attached? ?
Rails.application.routes.url_helpers.rails_blob_url(
@@ -49,4 +51,20 @@ class Post < ApplicationRecord
filename: 'resized_thumbnail.jpg',
content_type: 'image/jpeg')
end
private
def validate_original_created_range
f = original_created_from
b = original_created_before
return if f.blank? || b.blank?
f = Time.zone.parse(f) if String === f
b = Time.zone.parse(b) if String === b
return if !(f) || !(b)
if f >= b
errors.add :original_created_before, 'オリジナルの作成日時の順番がをかしぃです.'
end
end
end