Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
change_column :posts, :ID, :string, :null => false
add_column の後にこれを使用しましたが、値を空のままにしてもエラーは表示されません。エラーをキャプチャするために何ができますか?
モデル内で検証を使用する必要があります。
class Post < ActiveRecord::Base validates :column_name, presence: true end
また、文字列を保存するために :id を使用しない方がよいでしょう。この列名は Rails で予約されています。