0

After some research I had begun to start to name all my html divs using hyphens because I read that method carried the most benefits (Naming "class" and "id" HTML attributes - dashes vs. underlines). Now I realized why I was using underscores before and that's because rails uses them!

For example:

<%= select('test', 'foo', ........)

will generate

<select id="test_foo"........>

omitting 'test' gives

<select id="_foo".............>

as we can see, rails uses underscores when automatically prefixing/concatenating HTML ids. I was wondering why rails uses the underscore instead of a hyphen and if there's anyway to change this? Thank You!

Community
  • 1
  • 1
Steve
  • 4,446
  • 7
  • 35
  • 50

1 Answers1

1

It's related with conventions, where the underscore is used as separator. You should not think about change it because Rails is a very opinionated framework, and the best advise you can get is to stick with conventions. If you are trying to circumvent them, probably you are doing something wrong. Rethink it!

Paulo Fidalgo
  • 21,709
  • 7
  • 99
  • 115