2
2

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.

【Rails】マイクロポストの存在確認用のバリテーョンの追加方法

Last updated at Posted at 2017-08-08

Userモデルの名前属性とメール属性が存在するかどうかのバリテーョンを行う方法

railsのどこを見てFILL_INを記載するかは
views/users/index.html.erbで定義したものを記載

FILL_INの箇所にカラム名を書き込む

class User < ActiveRecord::Base
  has_many :microposts
  validates FILL_IN, presence: true
  validates FILL_IN, presence: true
end

のFILL_INをどのように記載するか
実際のコードは

class User < ApplicationRecord
   has_many :microposts
   validates :name, presence: true
   validates :email, presence: true
end

nameやemailだけだとその名前の変数ということになるので
:nameや:emailと記載する必要がある

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?