This blog is part of our Rails 5 series.
Before Rails 5, partials name should start with underscore and should be followed by any combination of letters, numbers and underscores.
This rule was required because before
rendering a partial without giving
:collection used to generate
a local variable with the partial name by default and
a variable name in ruby can’t have dash and other things like that.
In the following case we have a file named
Now let’s try to use this partial.
We will get following error, if we try to render above view in Rails 4.x.
In the above the code failed because the partial name has a dash which is not a valid ruby variable name.
In Rails 5, we can give our partials any name which starts with underscore.