开发者

rails 3, rules pluralization

I have created an application in Rails, I want to create a puccuentas model:

rails g scaffold puccuenta numero:integer pucgrupo_id:integer nombre:string

the output console is:

  invoke  active_record
  create    db/migrate/20110819163754_create_puccuentas.rb
  create    app/models/puccuenta.rb
  invoke    test_unit
  create      test/unit/puccuenta_test.rb
  create      test/fixtures/puccuentas.yml
   route  resources :puccuentas
  invoke  scaffold_controller
  create    app/controllers/puccuentas_controller.rb
  invoke    erb
  create      app/views/puccuentas
  create      app/views/puccuentas/index.html.erb
  create      app/views/puccuentas/edit.html.erb
  create      app/views/puccuentas/show.html.erb
  create      app/views/puccuentas/new.html.erb
  create      app/views/puccuentas/_form.html.erb
  invoke    test_unit
  create      test/functional/puccuentas_controller_test.rb
  invoke    helper
  create      app/helpers/puccuentas_helper.开发者_StackOverflowrb
  invoke      test_unit
  create        test/unit/helpers/puccuentas_helper_test.rb

my file inflection.rb

 ActiveSupport::Inflector.inflections do |inflect|
   inflect.plural /puccuenta$/i, '\1puccuentas'
   inflect.singular /puccuentas/i, '\1puccuenta'
 end

when entering the url http://localhost:3000/puccuentas

ActiveRecord::StatementInvalid in PuccuentasController#index

Mysql2::Error: Table 'proyecto_development.puccuenta' doesn't exist: SELECT `puccuenta`.* FROM `puccuenta`
Rails.root: /home/andres/desarrollos/rubyonrails/proyecto

Application Trace | Framework Trace | Full Trace
app/controllers/puccuentas_controller.rb:5:in `index'

I can see that the table is puccuenta, but I have defined pluralize puccuentas. What is the reason for the inflectors failure?

Thanks.


try
inflect.irregular 'puccuenta', 'puccuentas'

or create a regular one which is flexible, like
inflect.plural /^(a)$/i, '\1s'

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜