Create a separate ActiveRecord locale #10167

Closed
wants to merge 1 commit into
from

Projects

None yet

5 participants

@rubys

Decouples pluralization activities from the current locale.

#10158 changes pluralization to depend on the current locale, which breaks ActiveRecord which makes heavy use of pluralization and depends on this function returning consistent results. You can see the results http://intertwingly.net/projects/AWDwR4/checkdepot/section-15.2.html where we get a Could not find table 'cart' error message when we switch locales.

Preferred solutions are to either revert the original commit, or to give ActiveRecord a separate locale. This pull request implements the latter. I'm OK with either option.

@rubys rubys Create a separate ActiveRecord locale
Decouples pluralization activities from the current locale.
ee62a89
@josevalim
Ruby on Rails member

Thanks Sam!

I don't think we should allow people to use their own locale on Active Record column names, tables and friends. All of Ruby standard library, Rails API are in english. As someone who has seen projects using two idioms, mixing portuguese and english, I am really frightened by this change, because those are always the worst projects to work with.

@rubys

@josevalim I previously created rubys@9343eb7 but others seemed to prefer generalizing it. All I care is that setting the locale doesn't cause ActiveRecord to get 😕.

@rafaelfranca
Ruby on Rails member

@rubys I reverted the original commit at d716fe0 since it doesn't affect only Active Record

@rafaelfranca
Ruby on Rails member

Closing this now.

@mhuggins mhuggins commented on the diff Apr 10, 2013
...ord/connection_adapters/abstract/schema_statements.rb
@@ -175,7 +175,7 @@ def create_table(table_name, options = {})
unless options[:id] == false
pk = options.fetch(:primary_key) {
- Base.get_primary_key table_name.to_s.singularize
+ Base.get_primary_key ActiveRecord::Base.column_name_for(table_name)
@mhuggins
mhuggins Apr 10, 2013

Should this be calling table_name_for?

@rubys
rubys Apr 10, 2013

I'm not clear what get_primary_key(base_name) does. It is :nodoc:

That being said, table_name_for pluralizes and does different things based on the value of pluralize_table_names. column_name_for singularizes. I went with not changing the logic.

@steveklabnik
Ruby on Rails member

Dammit. Sorry about all this, everyone.

@steveklabnik
Ruby on Rails member

I don't think we should allow people to use their own locale on Active Record column names, tables and friends. All of Ruby standard library, Rails API are in english.

I can 👍 this, for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment