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のlabelで"CSVファイル"が"Csvファイル"になってしまう対応

Posted at
  • Railsをさわっていると、2年に一回くらいこの問題を調べる気がするのでメモを残しておきます

結論

第3引数に表示したい名前わたす

現象

単純にlabelの第2引数に文字列を渡すとCamelCaseになってしまいます。

<%= label :user, 'CSVファイル' %>
<label for="user_csv">Csvファイル</label>

解決策

本当は、第3引数の文字列がテキストで、第2引数はメソッドの定義のよう。

<%= label :user, 'csv', 'CSVファイル' %>
<label for="user_csv">CSVファイル</label>

参考

label(object_name, method, content_or_options = nil, options = nil, &block)

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?