Search code examples
ruby-on-railspluralize

Rails 2.3.9 pluralize model names issue


I'm developing a simple select. The thing is my code needs to be in spanish, so instead of using Role I have to use Rol (the plurar remains the same: Roles).

So, my model name is: Rol and my Controller name: Roles and in my DB: Roles

<% roles = Rol.all %>
<%=  collection_select(:usuario, :rol_id, roles, :id, :nombre, {:prompt => true}) %>

However, when I run that code I get:

ActiveRecord::JDBCError: Table 'turaser2.rols' doesn't exist: SELECT * FROM rols

(for obvious reasons)... So, my question is: how can I tell rails to look into the "roles" table instead the "rols" table?

Thank you!


Solution

  • The easiest way is to do something like:

    set_table_name "roles"
    

    in your model.