6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ActiveRecordのfind_zone!の話

Posted at

タイムスタンプの関係で

Time.zone_default =  Time.find_zone! 'Tokyo'
ActiveRecord::Base.default_timezone = :local

を使ったのですがなぜか失敗

「エラーにはTimeクラスにfind_zone!メソッドがない」とかなんとか

とてもつらい......

小一時間ググると海外フォーラムに同様の事例を発見

どうやらActiveSupportのメソッドらしい

さっそく投稿者に倣いActiveSupportを宣言

require "active_record"
require "pp"
require "active_support/all"

Time.zone_default =  Time.find_zone! 'Tokyo'
ActiveRecord::Base.default_timezone = :local

しっかり動いたので個人的には満足

でもActiveSupportのドキュメントが少なすぎてよくわからない様子

謎は深まるばかり

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?