モデル操作の勉強のためにユーザ情報にタイムゾーンの情報を追加するテストコードをかいているのですが
バリデーションの書き方がよくわかりません
https://qiita.com/takashisite/items/a06f38d00a853691fcd8
のとおりに
rb
1validates_inclusion_of :time_zone, 2 in: ActiveSupport::TimeZone.zones_map { |m| m.name }, 3 message: "is not a valid Time Zone"
とかいても
https://ruby-rails.hatenadiary.com/entry/20141217/1418817120
のとおりに
rb
1valications :time_zone, inclusion: { in: ActiveSupport::TimeZone.zones_map(&:name) }
とかいても
An object with the method #include? or a proc, lambda or symbol is required, and must be supplied as the :in (or :within) option of the configuration hash
というエラーになります
エラーの意味もよくわからないのですがどこが悪いのでしょうか…
回答1件
あなたの回答
tips
プレビュー