开发者

What if the model in the ActiveRecord is an always plural word?

开发者 https://www.devze.com 2023-03-19 05:13 出处:网络
I am developing a Rails app which should rely on existing database. There are a couple of table names there which are the always plural words, like \"Series\".

I am developing a Rails app which should rely on existing database. There are a couple of table names there which are the always plural words, like "Series".

Application is not working 开发者_如何学运维correctly with the models associated with them. How would you propose to deal with it - is there any solution without changing the naming?

Thanks in advance!


It sounds like you need to tell Rails that "Series" is uncountable - that is, that it shouldn't try inflecting it for singular/plural. To do this, add the line inflect.uncountable 'series' to your config/initializers/inflections.rb file.

Curiously, however, "series" appears to be uncountable by default; did you just pick it as an example out of a number of similar names?

0

精彩评论

暂无评论...
验证码 换一张
取 消