0
0

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 3 years have passed since last update.

Rails | migration で t.timestamp が動かない?

Last updated at Posted at 2015-12-07

timestamp (単数形) ではなくて timestamps (複数形) で書くこと。

単数形で書いても、特にエラーも出ないので注意。

db/create_example.rb
class CreateExample < ActiveRecord::Migration
  def change
    create_table :example do |t|
      t.string :requester
      - t.timestamp
      + t.timestamps
    end
  end
end

「created_at と updated_at の二個を作るので複数形」だと覚えれば良い。

環境

  • Rails 4.0.13

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

メンター受付

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?