Ticket #184 (new defect)

Opened 8 months ago

Last modified 8 months ago

[PATCH] updating translated model doesn't work with Rails 2.0

Reported by: artemv Assigned to:
Priority: major Milestone:
Component: model Version:
Keywords: Cc:

Description

It brings following error:

ArgumentError: wrong number of arguments (2 for 1)
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/locking/optimistic.rb:79:in `attributes_with_quotes'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/locking/optimistic.rb:79:in `update_without_callbacks'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/callbacks.rb:240:in `update_without_timestamps'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/timestamp.rb:38:in `globalize_old_update'
vendor/plugins/globalize-for-1.2/lib/globalize/localization/db_translate.rb:702:in `update'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/base.rb:2165:in `create_or_update_without_callbacks'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/callbacks.rb:213:in `globalize_old_create_or_update'
vendor/plugins/globalize-for-1.2/lib/globalize/localization/db_translate.rb:695:in `create_or_update'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/base.rb:1899:in `save_without_validation'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/validations.rb:901:in `save_without_transactions'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/transactions.rb:108:in `save'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/transactions.rb:80:in `transaction'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/transactions.rb:100:in `transaction'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/transactions.rb:108:in `save'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/transactions.rb:120:in `rollback_active_record_state!'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/transactions.rb:108:in `save'
/mypath/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.1/lib/active_record/base.rb:1961:in `update_attributes'
app/controllers/admin/department_controller.rb:53:in `update'

This is because method attributes_with_quotes has 2 arguments in Rails 2.0 and it's redefined in Globalize's db_translate.rb. Correct version of method: (also a patch is attached for Edge Globalize, though I still work with globalize-for-1.2 because edge Globalize gives me a handful of test failures)

        def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true)          
          if Locale.base?
            quoted = attributes.inject({}) do |quoted, (name, value)|
              if column = column_for_attribute(name)
                quoted[name] = quote_value(value, column) unless !include_primary_key && column.primary
              end
              quoted
            end
          else
            quoted = attributes.inject({}) do |quoted, (name, value)|
              if !self.class.globalize_facets_hash.has_key?(name) &&
                  column = column_for_attribute(name)
                quoted[name] = quote_value(value, column) unless !include_primary_key && column.primary
              end
              quoted
            end
          end
          include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)
        end

Attachments

attributes_with_quotes-2_0.patch (1.5 kB) - added by artemv on 12/12/07 08:27:43.

Change History

12/12/07 08:27:43 changed by artemv

  • attachment attributes_with_quotes-2_0.patch added.

12/12/07 08:47:06 changed by artemv

btw all the rest is fine - my globalize-for-1.2 works with Rails 2.0 after this fix