Home > Blockchain >  Fix deprecation warning for an internationalization locale suffix in ruby on rails 6.1
Fix deprecation warning for an internationalization locale suffix in ruby on rails 6.1

Time:02-28

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?

CodePudding user response:

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.

  • Related