8
7

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のcolumn名に special? とか付けたい時にどうするか。

Posted at

カラム名に?が使えないので真偽値を返すメソッドの末尾に?をつけて使いたいときにどうするかというお話。

解決策

例えば単にspecialってカラム名で列を追加して型をbooleanにしたらfoo.special?で呼び出せるようになる。すごい。

ちなみにこういう時に使える英単語に automagically というのがあります。プログラム関係でしか出てこないので英会話教室とかではまず出てこないので覚えておくと良いかもしれません。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?