---
title: "Partial template name without Ruby identifier Rails 5"
description:
  "Partial template can have any name which starts with underscore in Rails 5"
canonical_url: "https://www.bigbinary.com/blog/rails-5-partial-template-name-need-not-be-a-valid-ruby-identifier"
markdown_url: "https://www.bigbinary.com/blog/rails-5-partial-template-name-need-not-be-a-valid-ruby-identifier.md"
---

# Partial template name without Ruby identifier Rails 5

Partial template can have any name which starts with underscore in Rails 5

- Author: Prajakta Tambe
- Published: July 14, 2016
- Categories: Rails 5, Rails

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
[commit](https://github.com/rails/rails/commit/c67005f221f102fe2caca231027d9b11cf630484),
rendering a partial without giving `:object` or `: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 `_order-details.html.erb`. Now let's
try to use this partial.

```ruby

<!DOCTYPE html>
<html>
<body>
  <%= render :partial => 'order-details' %>
</body>
</html>
```

We will get following error, if we try to render above view in Rails 4.x.

```ruby
ActionView::Template::Error (The partial name (order-details) is not a valid Ruby identifier;
make sure your partial name starts with underscore,
and is followed by any combination of letters, numbers and underscores.):
2: <html>
3: <body>
4: Following code is rendered through partial named \_order-details.erb
5: <%= render :partial => 'order-details' %>
6: </body>
7: </html>
```

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](https://github.com/rails/rails/commit/da9038e).

## Links

- [Human page](https://www.bigbinary.com/blog/rails-5-partial-template-name-need-not-be-a-valid-ruby-identifier)
