# No sleep till cocoa! (works)

**URL:** <https://www.ruby-forum.com/t/no-sleep-till-cocoa-works/66426>\
**Category:** Ruby\
**Created:** [August 25, 2006, 1:17pm UTC](https://www.ruby-forum.com/t/no-sleep-till-cocoa-works/66426 "2006-08-25T13:17:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![slam-dunc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@slam-dunc](https://www.ruby-forum.com/u/slam-dunc)\
**Post date:** [August 25, 2006, 1:17pm UTC](https://www.ruby-forum.com/t/no-sleep-till-cocoa-works/66426/1 "2006-08-25T13:17:14Z")

</div>

Hi there I seem to have some issues with ruby cocoa and active record  
can anyone help?

The following works without problems

require ‘osx/cocoa’  
require ‘rubygems’  
OSX::NSBundle.bundleWithPath("/System/Library/Frameworks/IOBluetoothUI.framework").load

But when I bring Active Record to the table…

require ‘rubygems’  
require\_gem ‘activerecord’  
require ‘osx/cocoa’  
OSX::NSBundle.bundleWithPath("/System/Library/Frameworks/IOBluetoothUI.framework").load

ArgumentError: wrong number of arguments (0 for 1)  
from (irb):4:in `load’  
from (irb):4

It seems activerecord is redefining the load method in some way. I’m  
fairly new to Ruby and I’m a little stuck. Any ideas? I’ve already  
tried seperating the above into modules (active record and ruby cocoa  
stuff are in seperate name spaces (I think!) but this doesn’t seem to  
work.

Any help would be greatly appreciated!!

Cheers,

Duncan

---

<div class="post-metadata">

**Author:** ![slam-dunc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@slam-dunc](https://www.ruby-forum.com/u/slam-dunc)\
**Post date:** [August 25, 2006, 1:46pm UTC](https://www.ruby-forum.com/t/no-sleep-till-cocoa-works/66426/2 "2006-08-25T13:46:43Z")

</div>

On 25/08/06, Duncan M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It seems activerecord is redefining the load method in some way. I’m  
> fairly new to Ruby and I’m a little stuck. Any ideas? I’ve already  
> tried seperating the above into modules (active record and ruby cocoa  
> stuff are in seperate name spaces (I think!) but this doesn’t seem to  
> work.

ActiveSupport is the culprit. In dependencies.rb, we find:

class Object #:nodoc:  
def load(file, \*extras)  
super(file, \*extras)  
rescue Object =\> exception  
exception.blame\_file! file  
raise  
end

# …

RubyCocoa works by responding to method\_missing and despatching ObjC  
messages via ocm\_send; once ActiveSupport has had its evil (don’t get  
me started!) way, this will never happen.

You should be able to use this as a quick workaround:

OSX::NSBundle.bundleWithPath(“…snip…”).ocm\_send(:load)

Paul.

---

<div class="post-metadata">

**Author:** ![slam-dunc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@slam-dunc](https://www.ruby-forum.com/u/slam-dunc)\
**Post date:** [August 25, 2006, 2:07pm UTC](https://www.ruby-forum.com/t/no-sleep-till-cocoa-works/66426/3 "2006-08-25T14:07:27Z")

</div>

Paul B. wrote:

> On 25/08/06, Duncan M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > It seems activerecord is redefining the load method in some way. I’m  
> > fairly new to Ruby and I’m a little stuck. Any ideas? I’ve already  
> > tried seperating the above into modules (active record and ruby cocoa  
> > stuff are in seperate name spaces (I think!) but this doesn’t seem to  
> > work.
> 
> ActiveSupport is the culprit. In dependencies.rb, we find:
> 
> class Object #:nodoc:  
> def load(file, \*extras)  
> super(file, \*extras)  
> rescue Object =\> exception  
> exception.blame\_file! file  
> raise  
> end
> 
> # …
> 
> RubyCocoa works by responding to method\_missing and despatching ObjC  
> messages via ocm\_send; once ActiveSupport has had its evil (don’t get  
> me started!) way, this will never happen.
> 
> You should be able to use this as a quick workaround:
> 
> OSX::NSBundle.bundleWithPath(“…snip…”).ocm\_send(:load)
> 
> Paul.

Cheers for that everything is working fantastic!

I only wish I’d tried here about a week ago.

Thanks,

Duncan

---

<div class="post-metadata">

**Author:** ![slam-dunc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@slam-dunc](https://www.ruby-forum.com/u/slam-dunc)\
**Post date:** [August 26, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/no-sleep-till-cocoa-works/66426/4 "2006-08-26T14:44:38Z")

</div>

“Paul B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> RubyCocoa works by responding to method\_missing and despatching ObjC  
> messages via ocm\_send; once ActiveSupport has had its evil (don’t get  
> me started!) way, this will never happen.

RubyCocoa probably should use (a kind of?) BlankSlate, then?

---

<div class="post-metadata">

**Author:** ![slam-dunc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@slam-dunc](https://www.ruby-forum.com/u/slam-dunc)\
**Post date:** [August 26, 2006, 6:11pm UTC](https://www.ruby-forum.com/t/no-sleep-till-cocoa-works/66426/5 "2006-08-26T18:11:03Z")

</div>

On 26/08/06, Christian N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> “Paul B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:
> 
> > RubyCocoa works by responding to method\_missing and despatching ObjC  
> > messages via ocm\_send; once ActiveSupport has had its evil (don’t get  
> > me started!) way, this will never happen.
> 
> RubyCocoa probably should use (a kind of?) BlankSlate, then?

I don’t think that would help:

class BlankSlate  
instance\_methods.each { |m| undef\_method m unless m =~ /^\_\_/ }  
end

b = BlankSlate.new  
b.load rescue p $!

#\<NoMethodError: private method `load’ called for  
#BlankSlate:0x670858\>

require ‘active\_support’  
b = BlankSlate.new  
b.load rescue p $!

#\<ArgumentError: wrong number of arguments (0 for 1)\>

Paul.

---

<div class="post-metadata">

**Author:** ![slam-dunc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@slam-dunc](https://www.ruby-forum.com/u/slam-dunc)\
**Post date:** [August 27, 2006, 9:57am UTC](https://www.ruby-forum.com/t/no-sleep-till-cocoa-works/66426/6 "2006-08-27T09:57:34Z")

</div>

On 27/08/06, Christian N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You need to load blank slate after active\_support…

D’oh! Of course.

Paul.

---

<div class="post-metadata">

**Author:** ![slam-dunc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@slam-dunc](https://www.ruby-forum.com/u/slam-dunc)\
**Post date:** [August 27, 2006, 4:46am UTC](https://www.ruby-forum.com/t/no-sleep-till-cocoa-works/66426/7 "2006-08-27T04:46:36Z")

</div>

“Paul B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> b = BlankSlate.new  
> b.load rescue p $!
> 
> #\<ArgumentError: wrong number of arguments (0 for 1)\>

You need to load blank slate after active\_support…
