0

In a controller, I am rendering a page and providing the internationalization information with a locale_suffix. For example

def create
      ...
      render "new#{locale_suffix}"
end

A typical local_suffix might be 'fr' for france, so it would be rendering new.fr. Upgrading to rails 6.1.2.4, I am seeing the following deprecation warning

DEPRECATION WARNING: Rendering actions with '.' in the name is deprecated: clubs/new.fr

How do I fix this warning?

Obromios
  • 15,408
  • 15
  • 72
  • 127
  • 2
    You can change the file name to `new+fr.html.erb` and use `render 'new', variants: locale_suffix`. https://guides.rubyonrails.org/layouts_and_rendering.html#the-variants-option – max Feb 26 '22 at 12:17
  • Does this answer help? https://stackoverflow.com/questions/68836670/rails-6-1-4-deprecation-warning-rendering-actions-with – Masa Sakano Feb 26 '22 at 19:27
  • Thanks max, that works. Do you want to answer the question with this information or will I? Masa, the information is probably contained somewhere in that question, but max's suggestion is much easier to follow in this particular case. – Obromios Feb 26 '22 at 23:25
  • Feel free to answer it yourself - I have a few thousand answers. The reason it was deprechiated is that allowing dots created an ambigiuty in the path lookup so its better to look for an alternative solution. – max Feb 27 '22 at 09:07

1 Answers1

0

According to max's comments on the question, you can change the controller action to

def create
      ...
      render new:, variants: local_suffix
end

You may also want to change the file name from 'new.fr.html.erb` to 'new+fr.html.erb' as the dot in that position can cause ambiguities.

Obromios
  • 15,408
  • 15
  • 72
  • 127