LoginSignup
9
9

More than 5 years have passed since last update.

【Rails】ActiveAdmin内のjust-datetime-pickerでタイムゾーンをTokyoにする

Posted at

ActiveAdmin内でDateTimeオブジェクトを扱う際に、標準のテキストボックスに日時を入力する形式は少し不便です。

そんな時下記を使うと、カレンダーから日付をピックアップすることができます。
https://github.com/mspanc/just-datetime-picker

ただ、残念ながらUTCのみに対応しておらず、Tokyoのタイムゾーンで日付を入力することができません。

just-datetime-pickerをforkして修正された下記を使うと良いです。
https://github.com/adriantoman/just-datetime-picker

これをRailsのGemfileに書き込んで、任意のファイルのedit画面に下記を追記しましょう。

  f.input :datetime, as: :just_datetime_picker, :input_html => { :value => { :combined_value => resource.datetime.in_time_zone("Tokyo"), :date => resource.datetime.in_time_zone("Tokyo")}}

あとはうまいことTokyoゾーンで日付を入力することができます。

9
9
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
9
9