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:ハイフン付のclassセレクタを適応する方法

Posted at

問題

railsのヘルパーメソッドに「ー」付のclassセレクタを適応させようとした時、エラーが発生した。
エラー発生コード <%=link_to '商品一覧', '#', class: [:btn, :btn-primary] %>

解決策

上記の「btn-primary」ように、ハイフンが付いているclassを適応したい場合は
エラー解消コード <%=link_to '商品一覧', '#', class: [:btn, :"btn-primary"] %>
このように「""」で囲ってあげる事で、classセレクタを適応することができる。

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?