If you use another language to name your model/controller/tables, how can you tweak the pluralization rules so that the overall Rails system behaves like you are used to?
You could open the inflector (as suggested below), but you can easily add rules in Rails by changing the file app/config/environment.rb.
Another suggestion is to simply call the
set_table_namemethod in your model
class Modulgruppe < ActiveRecord::Base
set_table_name 'modulgruppen'
belongs_to :veranstaltung
end
but this only refers to the actual table name you are using in the DB. What if you want to REALLY change the pluralization rules so that you can write with correct pluralization in every place?
class Veranstaltung < ActiveRecord::Base
#should be able to write
has_many :modulgruppen
# instead of enlish plural
has_many :modulgruppes
end
singular_rules and plural_rulesThe inflector (which is a part of ActiveSupport, Inflector API reference) has two methods that contain the rules for (english) pluralization and singularization. Thanks to the nature of Ruby, the Inflector class can be opened up, and those two methods can be re-defined to return an alternate set of rules that could provide for pluralization in another language.
See Also: HowToUseLegacySchemas
See also: InflectorInCSharp
category: OpenQuestion