[Rubycocoa-devel 1293] Re: reflect_on_all_associations error

アーカイブの一覧に戻る

Randy Harmon rjhar****@yahoo*****
Sun Jan 27 03:27:38 JST 2008


From: Eloy Duran <e.dur****@super*****>

> This is probably because of the recent speed improvements I added.

> Could you try to change the Emails ActiveRecordSetController into a BelongsToActiveRecordSetController?





Thanks, Eloy.  I've made some small progress that may be helpful for helping you help me.  Er.. 

Here's what I know:

I had used ActiveRecordSetController, and I did switch Emails to use BelongsToActiveRecordSetController (after my post).  I'm currently getting errors (yellow "yield" icon) in Interface Builder, suggesting that add: and remove: are not known methods of these classes (ActiveRSC or BTARSC).  I'm not sure why Interface Builder started not knowing about these classes (maybe it never did know about them? but I did get a Mailbox record added at one time).

I had Interface Builder read the active_record.rb class file, and I was able to get rid of the IB errors.  However, my application is still aborting . On Emails (with BelongsToActiveRecordSetController), that call stack is as follows (#1). 

I deleted SQLite file, added one Mailbox: OK; add second Mailbox: dies.  See call stack #2.  

I deleted SQLite file again, to avoid the Mailbox error.  When I to add the first Email record, I get one error (app exits, but the record is added).  When I run again and add the second Email, I get a different error (record not added).  I have added a to_yaml() call on the record at active_record.rb:275 in is_association? - see the full log from this process below (starting from second SQLite deletion).


thanks for any light you can shed on this issue.

Randy


#1 call stack:

2008-01-26 10:00:04.065 MailDemo200801[37979:10b] OSX::BelongsToActiveRecordSetController#newObject: NoMethodError: undefined method `reflect_on_all_associations' for NilClass
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:751:in `method_missing'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:278:in `is_association?'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:377:in `initialize'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `ocm_send'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `method_missing'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:91:in `newObject'
    /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25:in `NSApplicationMain'
    /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25
/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:751:in `method_missing': undefined method `reflect_on_all_associations' for NilClass (NoMethodError)
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:278:in `is_association?'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:377:in `initialize'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `ocm_send'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `method_missing'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:91:in `newObject'
    from /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25:in `NSApplicationMain'
    from /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25

#2 call stack:

2008-01-26 10:09:44.947 MailDemo200801[38023:10b] OSX::ActiveRecordSetController#newObject: NoMethodError: undefined method `reflect_on_all_associations' for NilClass
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:751:in `method_missing'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:278:in `is_association?'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:377:in `initialize'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:72:in `objectClass'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:72:in `newObject'
    /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25:in `NSApplicationMain'
    /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25
/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:751:in `method_missing': undefined method `reflect_on_all_associations' for NilClass (NoMethodError)
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:278:in `is_association?'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:377:in `initialize'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:72:in `objectClass'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:72:in `newObject'
    from /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25:in `NSApplicationMain'
    from /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25


Full application log with extra dumps of record objects:


[Session started at 2008-01-26 10:22:20 -0800.]
SQL (0.008905)  CREATE TABLE schema_info (version integer)
SQL (0.011375)  INSERT INTO schema_info (version) VALUES(0)
SQL (0.000000)  SQLite3::SQLException: table schema_info already exists: CREATE TABLE schema_info (version integer)
SQL (0.000766)  SELECT version FROM schema_info
Migrating to CreateMailboxes (1)
== CreateMailboxes: migrating =================================================
-- create_table(:mailboxes)
SQL (0.003376)  CREATE TABLE mailboxes ("id" INTEGER PRIMARY KEY NOT NULL, "name" varchar(255) DEFAULT 'New Mailbox') 
   -> 0.0041s
== CreateMailboxes: migrated (0.0043s) ========================================

SQL (0.001879)  UPDATE schema_info SET version = 1
SQL (0.000436)  SELECT version FROM schema_info
Migrating to CreateEmails (2)
== CreateEmails: migrating ====================================================
-- create_table(:emails)
SQL (0.001883)  CREATE TABLE emails ("id" INTEGER PRIMARY KEY NOT NULL, "mailbox_id" integer DEFAULT NULL, "sender" varchar(255) DEFAULT 'sender', "subject" varchar(255) DEFAULT 'subject', "body" text DEFAULT NULL, "created_at" datetime DEFAULT NULL) 
   -> 0.0028s
== CreateEmails: migrated (0.0030s) ===========================================

SQL (0.001666)  UPDATE schema_info SET version = 2
connected to db?
Mailbox Load (0.000469)  SELECT * FROM mailboxes 
SQL (0.000517)  INSERT INTO mailboxes ("name") VALUES('New Mailbox')
------- dumping record ---------------
--- &id001 !ruby/object:Mailbox 
attributes: 
  name: New Mailbox
  id: 1
errors: !ruby/object:ActiveRecord::Errors 
  base: *id001
  errors: {}

new_record: false
new_record_before_save: true
--------end of record --------------
Email Load (0.000338)  SELECT * FROM emails WHERE (emails.mailbox_id = 1) 
------- dumping record ---------------
--- &id001 !ruby/object:Mailbox 
attributes: 
  name: New Mailbox
  id: 1
emails: []

errors: !ruby/object:ActiveRecord::Errors 
  base: *id001
  errors: {}

new_record: false
new_record_before_save: true
--------end of record --------------
SQL (0.000555)  INSERT INTO emails ("body", "sender", "subject", "created_at", "mailbox_id") VALUES(NULL, 'sender', 'subject', '2008-01-26 10:22:26', NULL)
------- dumping record ---------------
--- &id001 !ruby/object:Mailbox 
attributes: 
  name: New Mailbox
  id: 1
emails: []

errors: !ruby/object:ActiveRecord::Errors 
  base: *id001
  errors: {}

new_record: false
new_record_before_save: true
--------end of record --------------
------- dumping record ---------------
--- &id001 !ruby/object:Mailbox 
attributes: 
  name: New Mailbox
  id: 1
emails: []

errors: !ruby/object:ActiveRecord::Errors 
  base: *id001
  errors: {}

new_record: false
new_record_before_save: true
--------end of record --------------
Email Update (0.000592)  UPDATE emails SET "created_at" = '2008-01-26 10:22:26', "sender" = 'sender', "subject" = 'subject', "mailbox_id" = 1, "body" = NULL WHERE "id" = 1
------- dumping record ---------------
--- &id002 !ruby/object:Mailbox 
attributes: 
  name: New Mailbox
  id: 1
emails: 
- &id001 !ruby/object:Email 
  attributes: 
    body: 
    sender: sender
    id: 1
    subject: subject
    created_at: 2008-01-26 10:22:26.231353 -08:00
    mailbox_id: 1
  errors: !ruby/object:ActiveRecord::Errors 
    base: *id001
    errors: {}

  new_record: false
errors: !ruby/object:ActiveRecord::Errors 
  base: *id002
  errors: {}

new_record: false
new_record_before_save: true
--------end of record --------------
------- dumping record ---------------
--- 
--------end of record --------------
2008-01-26 10:22:26.273 MailDemo200801[38076:10b] MailboxProxy#rbValueForKey: NoMethodError: undefined method `reflect_on_all_associations' for NilClass
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:751:in `method_missing'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:278:in `is_association?'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:377:in `initialize'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:40:in `new_with_ocid'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:40:in `alloc'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:40:in `to_activerecord_proxy'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:48:in `to_activerecord_proxies'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:48:in `map'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:48:in `to_activerecord_proxies'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/association_proxy.rb:123:in `send'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/association_proxy.rb:123:in `method_missing'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/has_many_association.rb:98:in `method_missing'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:294:in `rbValueForKey'
    /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25:in `NSApplicationMain'
    /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25
------- dumping record ---------------
--- 
--------end of record --------------
/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:751:in `method_missing': undefined method `reflect_on_all_associations' for NilClass (NoMethodError)
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:278:in `is_association?'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:377:in `initialize'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:751:in `NSApplicationMain'
    from /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25

The Debugger has exited with status 1.The Debugger has exited with status 1.

[Session started at 2008-01-26 10:22:29 -0800.]
SQL (0.000000)  SQLite3::SQLException: table schema_info already exists: CREATE TABLE schema_info (version integer)
SQL (0.000000)  SQLite3::SQLException: table schema_info already exists: CREATE TABLE schema_info (version integer)
SQL (0.000815)  SELECT version FROM schema_info
SQL (0.000345)  SELECT version FROM schema_info
connected to db?
Mailbox Load (0.000406)  SELECT * FROM mailboxes 
------- dumping record ---------------
--- &id001 !ruby/object:Mailbox 
attributes: 
  name: New Mailbox
  id: "1"
record_proxy: !ruby/object:MailboxProxy 
  record: *id001
--------end of record --------------
Email Load (0.000557)  SELECT * FROM emails WHERE (emails.mailbox_id = 1) 
------- dumping record ---------------
--- &id001 !ruby/object:Email 
attributes: 
  body: 
  sender: sender
  id: "1"
  subject: subject
  mailbox_id: "1"
  created_at: 2008-01-26 10:22:26
record_proxy: !ruby/object:EmailProxy 
  record: *id001
--------end of record --------------
------- dumping record ---------------
--- &id002 !ruby/object:Mailbox 
attributes: 
  name: New Mailbox
  id: "1"
emails: 
- &id001 !ruby/object:Email 
  attributes: 
    body: 
    sender: sender
    id: "1"
    subject: subject
    mailbox_id: "1"
    created_at: 2008-01-26 10:22:26
  record_proxy: !ruby/object:EmailProxy 
    record: *id001
record_proxy: !ruby/object:MailboxProxy 
  record: *id002
--------end of record --------------
------- dumping record ---------------
--- &id001 !ruby/object:Email 
attributes: 
  body: 
  sender: sender
  id: "1"
  subject: subject
  mailbox_id: "1"
  created_at: 2008-01-26 10:22:26
record_proxy: !ruby/object:EmailProxy 
  record: *id001
--------end of record --------------
------- dumping record ---------------
--- &id001 !ruby/object:Email 
attributes: 
  body: 
  sender: sender
  id: "1"
  subject: subject
  mailbox_id: "1"
  created_at: 2008-01-26 10:22:26
record_proxy: !ruby/object:EmailProxy 
  record: *id001
--------end of record --------------
------- dumping record ---------------
--- &id001 !ruby/object:Email 
attributes: 
  body: 
  sender: sender
  id: "1"
  subject: subject
  mailbox_id: "1"
  created_at: 2008-01-26 10:22:26
record_proxy: !ruby/object:EmailProxy 
  record: *id001
--------end of record --------------
------- dumping record ---------------
--- &id002 !ruby/object:Mailbox 
attributes: 
  name: New Mailbox
  id: "1"
emails: 
- &id001 !ruby/object:Email 
  attributes: 
    body: 
    sender: sender
    id: "1"
    subject: subject
    mailbox_id: "1"
    created_at: 2008-01-26 10:22:26
  record_proxy: !ruby/object:EmailProxy 
    record: *id001
record_proxy: !ruby/object:MailboxProxy 
  record: *id002
--------end of record --------------
------- dumping record ---------------
--- 
--------end of record --------------
2008-01-26 10:22:33.275 MailDemo200801[38077:10b] OSX::ActiveRecordSetController#newObject: NoMethodError: undefined method `reflect_on_all_associations' for NilClass
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:751:in `method_missing'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:278:in `is_association?'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:377:in `initialize'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `ocm_send'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `method_missing'
    /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:72:in `newObject'
    /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25:in `NSApplicationMain'
    /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25
/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:751:in `method_missing': undefined method `reflect_on_all_associations' for NilClass (NoMethodError)
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:278:in `is_association?'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:377:in `initialize'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `ocm_send'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `method_missing'
    from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/active_record.rb:72:in `newObject'
    from /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25:in `NSApplicationMain'
    from /Users/rjh/MailDemo20080123/build/Debug/MailDemo200801.app/Contents/Resources/rb_main.rb:25

The Debugger has exited with status 1.The Debugger has exited with status 1.


---- end ----






-------------- next part --------------
An HTML attachment was scrubbed...
ダウンロード 


More information about the Rubycocoa-devel mailing list
アーカイブの一覧に戻る