Daniel Berger
2006-Mar-28 21:49 UTC
[Rails] Problem with ActiveRecord, create, save, and Oracle adapter?
Hi all, Ruby 1.8.4 Rails 1.1 OCI8 0.1.14 I think I''m hitting an issue with ActiveRecord::Base#save and the Oracle adapter. Line 158 in the schedules_controller.rb file is simply: 158: if @schedule.save 159: flash[:notice] = ''Schedule was successfully created.'' 160: redirect_to :action => ''list'' 161: else 162: render :action => ''new'' 163: end Here''s the error (which is the same as what''s in the dev log): ArgumentError in Schedules#create wrong number of arguments (1 for 0) /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/oracle_adapter.rb:53:in `attributes_with_quotes_pre_oracle'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/oracle_adapter.rb:53:in `attributes_with_quotes'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:2031:in `quoted_column_names'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1735:in `create_without_callbacks'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/callbacks.rb:261:in `create_without_timestamps'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/timestamp.rb:30:in `create'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1712:in `create_or_update_without_callbacks'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/callbacks.rb:249:in `create_or_update'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/base.rb:1388:in `save_without_validation'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/validations.rb:724:in `save_without_transactions'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/transactions.rb:126:in `save'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/transactions.rb:91:in `transaction'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/transactions.rb:118:in `transaction'' /opt/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/transactions.rb:126:in `save'' #{RAILS_ROOT}/app/controllers/schedules_controller.rb:158:in `create'' Parameters: {"commit"=>"Create", "schedule"=>{"start_date_id"=>"30", "clli_code"=>"TEST", "slot_id"=>"1", "hardware_id"=>"6", "state_id"=>"6"}} Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} Any ideas? Thanks, Dan
Daniel Berger
2006-Mar-28 22:39 UTC
[Rails] Problem with ActiveRecord, create, save, and Oracle adapter?
Daniel Berger wrote:> Hi all, > > Ruby 1.8.4 > Rails 1.1 > OCI8 0.1.14 > > I think I''m hitting an issue with ActiveRecord::Base#save and the Oracle > adapter.<snip> It''s a bug. Try this patch: >diff -u oracle_adapter.orig oracle_adapter.rb --- oracle_adapter.orig Tue Mar 28 15:00:06 2006 +++ oracle_adapter.rb Tue Mar 28 15:01:20 2006 @@ -44,11 +44,7 @@ # Enable the id column to be bound into the sql later, by the adapter''s insert method. # This is preferable to inserting the hard-coded value here, because the insert method # needs to know the id value explicitly. - def attributes_with_quotes_pre_oracle #:nodoc: - attributes_with_quotes - end - - + alias :attributes_with_quotes_pre_oracle :attributes_with_quotes #:nodoc: def attributes_with_quotes(creating = true) #:nodoc: aq = attributes_with_quotes_pre_oracle creating if connection.class == ConnectionAdapters::OracleAdapter Regards, Dan
Michael Schoen
2006-Mar-29 18:10 UTC
[Rails] Problem with ActiveRecord, create, save, and Oracle adapter?
Daniel Berger wrote:> It''s a bug. Try this patch:The patch has also been posted to Trac, waiting for it to be applied.
Berger, Daniel
2006-Mar-29 21:01 UTC
[Rails] Problem with ActiveRecord, create, save, and Oracle adapter?
> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of > Michael Schoen > Sent: Wednesday, March 29, 2006 10:53 AM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] Problem with ActiveRecord, create, > save,and Oracle adapter? > > > Daniel Berger wrote: > > It''s a bug. Try this patch: > > The patch has also been posted to Trac, waiting for it to be > applied. _______________________________________________Thanks Michael. A larger question, that I didn''t think of yesterday, was why am I seeing this bug in the first place if I''m not even using the Oracle adapter? I''m using PostgreSQL. Does ActiveRecord try to load *all* the adapters or something? Regards, Dan
Michael Schoen
2006-Mar-29 23:26 UTC
[Rails] Problem with ActiveRecord, create, save, and Oracle adapter?
Berger, Daniel wrote:> Does ActiveRecord try to load *all* the adapters or something?Yes, all adapters are loaded by default. There''s a config option to only load specific adapters, but it causes an error if you''re running from a gem install of Rails.