Ruby on the pluralization rails help?

Possible duplicate:
How to override rails naming conventions?

My application will be in Spanish. Let's say I want the scaffold to generate actividad. The plural will be actividades, so I want the table and controller to be named like this .... how can I do this?

+5
source share
3 answers

Put the following code in config / environment.rb:

Inflector.inflections do |inflect|
  inflect.irregular 'actividad', 'actividades'
end

Check the code in the console (script / console):

'actividad'.pluralize
'actividades'.singularize

More details can be found here: http://codeidol.com/other/rubyckbk/Web-Development-Ruby-on-Rails/Understanding-Pluralization-Rules/

+10
source

Rails, . Rails inflections.rb /config/initializers. , . ( Rails):

# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
#   inflect.plural /^(ox)$/i, '\1en'
#   inflect.singular /^(ox)en/i, '\1'
#   inflect.irregular 'person', 'people'
#   inflect.uncountable %w( fish sheep )
# end

ActiveSupport::Inflector.inflections do |inflect|
  inflect.plural(/rion$/ ,'ria') # criterion => criteria
  inflect.singular(/ria$/, 'rion') # criteria => criterion
end
+6

, i18n api, / .

+3

All Articles