Can't find a route with an underscore or doesn't treat it properly

点点圈 提交于 2019-12-02 01:08:06

Rails inflects _ to be a word separator, so it searches for Api::V34 you can change that behavior by editing config/initializers/inflections.rb:

ActiveSupport::Inflector.inflections(:en) do |inflect|
  inflect.acronym 'V3_4'
end

Moreover, if you want to change Api namespace to API, since it's an acronym, you can do it there as well:

ActiveSupport::Inflector.inflections(:en) do |inflect|
  inflect.acronym 'V3_4'
  inflect.acronym 'API'
end

More info: http://api.rubyonrails.org/classes/ActiveSupport/Inflector/Inflections.html

The Ruby-Style-Guide helped me a lot to clarify these questions. Please see the naming section.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!