Charles Munat
2007-Oct-23 22:16 UTC
wrong number of arguments (2 for 1) attributes_with_quotes
I get this error whenever I use update_attributes. I am using rails v.8008. I''ve uninstalled the rails gem, so I am definitely using the rails in vendor/rails (v. 8008). There was a change made to attributes_with_quotes to add a second argument: # Returns copy of the attributes hash where all the values have been # safely quoted for use in an SQL statement. def attributes_with_quotes( include_primary_key = true, include_readonly_attributes = true ) 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 include_readonly_attributes ? quoted : remove_readonly_attributes(quoted) end The call in base.rb:1998 looks like this: # Updates the associated record with values matching those # of the instance attributes. Returns the number of affected rows. def update quoted_attributes = attributes_with_quotes(false, false) Here is the stack trace: vendor/rails/activerecord/lib/active_record/base.rb:1998:in `attributes_with_quotes'' vendor/rails/activerecord/lib/active_record/base.rb:1998:in `update_without_lock'' vendor/rails/activerecord/lib/active_record/locking/optimistic.rb:70:in `update_without_callbacks'' vendor/rails/activerecord/lib/active_record/callbacks.rb:240:in `update_without_timestamps'' vendor/rails/activerecord/lib/active_record/timestamp.rb:38:in `update'' vendor/rails/activerecord/lib/active_record/base.rb:1991:in `create_or_update_without_callbacks'' vendor/rails/activerecord/lib/active_record/callbacks.rb:213:in `create_or_update'' vendor/rails/activerecord/lib/active_record/base.rb:1743:in `save_without_validation'' vendor/rails/activerecord/lib/active_record/validations.rb:891:in `save_without_transactions'' vendor/rails/activerecord/lib/active_record/transactions.rb:105:in `save'' vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'' vendor/rails/activerecord/lib/active_record/transactions.rb:77:in `transaction'' vendor/rails/activerecord/lib/active_record/transactions.rb:97:in `transaction'' vendor/rails/activerecord/lib/active_record/transactions.rb:105:in `save'' vendor/rails/activerecord/lib/active_record/transactions.rb:117:in `rollback_active_record_state!'' vendor/rails/activerecord/lib/active_record/transactions.rb:105:in `save'' vendor/rails/activerecord/lib/active_record/base.rb:1790:in `update_attributes'' app/controllers/users_controller.rb:57:in `update_password'' app/controllers/users_controller.rb:56:in `update_password'' /usr/local/bin/mongrel_rails:18:in `load'' /usr/local/bin/mongrel_rails:18 It looks to me like attributes_with_quotes takes two arguments, so I do not understand "(2 for 1)." This was working fine before upgrading to the latest Edge Rails. Any ideas as to what the problem might be? Thanks, Chas. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
bmunat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-23 23:54 UTC
Re: wrong number of arguments (2 for 1) attributes_with_quotes
Definitely very weird... not seeing anything in base or optimistic that could cause this to screw up. I would say that maybe there''s a plugin overriding that method somewhere, but you would think that would show up in the stack trace then. Well, first, for a sanity check, create a new project and just make a simple table and model. See if you get the error there. I doubt you will or someone else would have complained about this (not finding anything in the rails trac). Also, try grepping through the entire project for anything that might redefine attributes_with_quotes. Ultimately, if you can''t sort it out, I would open a bug and roll back to a previous revision. b On Oct 23, 12:16 pm, Charles Munat <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I get this error whenever I use update_attributes. I am using rails > v.8008. I''ve uninstalled the rails gem, so I am definitely using the > rails in vendor/rails (v. 8008). > > There was a change made to attributes_with_quotes to add a second > argument: > > # Returns copy of the attributes hash where all the values have been > # safely quoted for use in an SQL statement. > def attributes_with_quotes( > include_primary_key = true, include_readonly_attributes = true ) > 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 > include_readonly_attributes ? quoted : > remove_readonly_attributes(quoted) > end > > The call in base.rb:1998 looks like this: > > # Updates the associated record with values matching those > # of the instance attributes. Returns the number of affected rows. > def update > quoted_attributes = attributes_with_quotes(false, false) > > Here is the stack trace: > > vendor/rails/activerecord/lib/active_record/base.rb:1998:in > `attributes_with_quotes'' > vendor/rails/activerecord/lib/active_record/base.rb:1998:in > `update_without_lock'' > vendor/rails/activerecord/lib/active_record/locking/optimistic.rb:70:in > `update_without_callbacks'' > vendor/rails/activerecord/lib/active_record/callbacks.rb:240:in > `update_without_timestamps'' > vendor/rails/activerecord/lib/active_record/timestamp.rb:38:in `update'' > vendor/rails/activerecord/lib/active_record/base.rb:1991:in > `create_or_update_without_callbacks'' > vendor/rails/activerecord/lib/active_record/callbacks.rb:213:in > `create_or_update'' > vendor/rails/activerecord/lib/active_record/base.rb:1743:in > `save_without_validation'' > vendor/rails/activerecord/lib/active_record/validations.rb:891:in > `save_without_transactions'' > vendor/rails/activerecord/lib/active_record/transactions.rb:105:in > `save'' > vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in > `transaction'' > vendor/rails/activerecord/lib/active_record/transactions.rb:77:in > `transaction'' > vendor/rails/activerecord/lib/active_record/transactions.rb:97:in > `transaction'' > vendor/rails/activerecord/lib/active_record/transactions.rb:105:in > `save'' > vendor/rails/activerecord/lib/active_record/transactions.rb:117:in > `rollback_active_record_state!'' > vendor/rails/activerecord/lib/active_record/transactions.rb:105:in > `save'' > vendor/rails/activerecord/lib/active_record/base.rb:1790:in > `update_attributes'' > app/controllers/users_controller.rb:57:in `update_password'' > app/controllers/users_controller.rb:56:in `update_password'' > /usr/local/bin/mongrel_rails:18:in `load'' > /usr/local/bin/mongrel_rails:18 > > It looks to me like attributes_with_quotes takes two arguments, so I do > not understand "(2 for 1)." > > This was working fine before upgrading to the latest Edge Rails. > > Any ideas as to what the problem might be? > > Thanks, > > Chas. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Charles Munat
2007-Oct-24 08:41 UTC
Re: wrong number of arguments (2 for 1) attributes_with_quot
The problem was with the Better Nested Set plugin. This: def attributes_with_quotes(include_primary_key = true) #:nodoc: attributes.inject({}) do |quoted, (name, value)| if column = column_for_attribute(name) quoted[name] = quote_value(value, column) unless !include_primary_key && (column.primary || [acts_as_nested_set_options[:left_column], acts_as_nested_set_options[:right_column]].include?(column.name)) end quoted end end Should be this: def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true) #:nodoc: 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 || [acts_as_nested_set_options[:left_column], acts_as_nested_set_options[:right_column]].include?(column.name)) end quoted end include_readonly_attributes ? quoted : remove_readonly_attributes(quoted) end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bruno Reis
2007-Dec-23 17:45 UTC
Re: wrong number of arguments (2 for 1) attributes_with_quot
Hey Charles, I also found that when I had an old rails installation this error would not show up. I dont know why ( maybe because acts_asnested_set was also installed ? ). Now that I switched to rails 2 (2.0.2) I got this error too, but I fixed with your code. Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---