# Running activerecord

**URL:** <https://www.ruby-forum.com/t/running-activerecord/135185>\
**Category:** IronRuby\
**Created:** [April 18, 2008, 10:47pm UTC](https://www.ruby-forum.com/t/running-activerecord/135185 "2008-04-18T22:47:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Blackwell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@Brian\_Blackwell](https://www.ruby-forum.com/u/Brian_Blackwell)\
**Post date:** [April 18, 2008, 10:47pm UTC](https://www.ruby-forum.com/t/running-activerecord/135185/1 "2008-04-18T22:47:33Z")

</div>

I wanted to test my prototype [ADO.NET](http://ADO.NET) database wrappers for SQLite and  
MySQL, so I thought I would see how far I could get in an attempt to run  
activerecord. Running activerecord is of course a necessary step in the  
path to running Rails. At this point I’m simply trying to get “require  
‘active\_record.rb’” to work, which in turn requires activesupport. Here  
are some issues I’ve come across thus far:

(1) Missing method File.expand\_path

- Adapted the implementation from [Ruby.NET](http://Ruby.NET), along with some other  
unimplemented methods from File. I will check on licensing issues  
before posting a patch.

(2) rubygems is not yet running in IronRuby

- Commented out all “require ‘rubygems’” in the activerecord and  
activesupport source, since they are not absolutely necessary (i.e.  
rubygems is used to grab packages not present on the local  
filesystem).

(3) Missing method Class.method\_added

- This is just a ‘dummy’ method that gets overridden - see patch for  
ModuleOps.cs

(4)  
C:\brian\ironruby\trunk\src\IronRuby.Libraries\Builtins\Kernel.cs:611:in  
`InstanceEval’: instance\_eval on Module or Class needs singleton support  
(NotImplementedError)

- It seems that instance\_eval has different semantics when invoked  
with a class or method as receiver. I haven’t yet worked out what is  
involved with implementing this method, so for the time being I  
commented out the NotImplementedError in Kernel.cs:  
//if (self is RubyModule) {  
// throw  
RubyExceptions.CreateNotImplementedError(“instance\_eval on  
Module or Class needs singleton support”);  
//}

(5) :0:in ` __init__': wrong number or type of arguments for `define\_method’ (ArgumentError)

- Problem: current implementation of define\_method does not accept  
Proc objects as arguments, hence the following line in  
activesupport-2.0.2\lib\active\_support\core\_ext\module\attr\_accessor\_with\_default.rb  
throws an exception:

- Solution: added an overload for DefineMethod that accepts a Proc  
object as an argument; see patch for ModuleOps.cs

(6) Missing method Thread.critical

- Hacked a prototype implementation - see patch for ThreadOps.cs (it’s  
ugly and purely for the purposes of trying to get activerecord  
to import 🙂

(7) Missing method Dir.glob

- Adapted the implementation from [Ruby.NET](http://Ruby.NET) (see (1) above)

(8) Missing method File.basename

- Adapted the implementation from [Ruby.NET](http://Ruby.NET) (see (1) above)

(9) Problem with  
activesupport-2.0.2\lib\active\_support\core\_ext\array\conversions.rb

- unknown: Cannot cast from ‘Microsoft.Scripting.SymbolId’ to  
‘Ruby.Builtins.Proc’  
(ArgumentError)

- This is the offending piece of code in conversions.rb:

- For the time being I have commented out this method in  
conversions.rb.

(10) Libraries ‘enumerator.so’ and ‘bigdecimal.so’ not available

- Solution: commented out the requires in the activesupport source for  
the time being

(11) Problem with the Ruby library ‘rational.rb’:  
:0:in `main’: Can’t inherit from a class without a default or code  
context constructor (System::NotSupportedException)

- The problem is that Rational is a subclass of Numeric, which is an  
abstract class with no constructor:  
class Rational \< Numeric
- Solution: hacked Ruby.Builtins.Numeric so that it is no longer  
abstract, and has a zero-arg constructor - see patch for Numeric.cs

(12)  
C:\brian\ironruby\trunk\src\IronRuby.Libraries\Builtins\Kernel.cs:804:in  
`Require’: Expression transformation not implemented:  
MemberAssignmentExpression (System::NotImplementedException)

- The problem is in the Ruby library date/format.rb, although I  
haven’t narrowed it down further than that.
- Solution: commented out all “require ‘date’” for the time being

(13) Problem with the Ruby library delegate.rb: Class.new not supported  
(e.g. no zero-arg constructor for “Class”)

This is as far as I have got at this point - hopefully someone might  
find all this useful.

- Brian

---

<div class="post-metadata">

**Author:** ![Brian\_Blackwell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@Brian\_Blackwell](https://www.ruby-forum.com/u/Brian_Blackwell)\
**Post date:** [April 19, 2008, 12:57am UTC](https://www.ruby-forum.com/t/running-activerecord/135185/2 "2008-04-19T00:57:36Z")

</div>

Brian Blackwell:

> I wanted to test my prototype [ADO.NET](http://ADO.NET) database wrappers for SQLite and  
> MySQL, so I thought I would see how far I could get in an attempt to  
> run activerecord. Running activerecord is of course a necessary step in  
> the path to running Rails. At this point I’m simply trying to get  
> “require ‘active\_record.rb’” to work, which in turn requires  
> activesupport. Here are some issues I’ve come across thus far:
> 
> … awesome list of observations elided …

Thanks for doing this work, Brian! This will give me a bunch of things  
to look at around the core libs this weekend.

-John

---

<div class="post-metadata">

**Author:** ![Brian\_Blackwell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@Brian\_Blackwell](https://www.ruby-forum.com/u/Brian_Blackwell)\
**Post date:** [May 22, 2008, 12:31am UTC](https://www.ruby-forum.com/t/running-activerecord/135185/3 "2008-05-22T00:31:35Z")

</div>

Hey Brian - can you share your prototype [ADO.NET](http://ADO.NET) wrappers for SQLite?  
We’re at the point where we need a DB to boot Rails.

Thanks,  
-John

---

<div class="post-metadata">

**Author:** ![Brian\_Blackwell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@Brian\_Blackwell](https://www.ruby-forum.com/u/Brian_Blackwell)\
**Post date:** [April 19, 2008, 2:13am UTC](https://www.ruby-forum.com/t/running-activerecord/135185/4 "2008-04-19T02:13:35Z")

</div>

I submitted an implementation of File.expand\_path a while ago but it  
hasn’t  
been comitted yet. If your implementation works better go for it. I need  
it  
for some things I’m doing with IronRuby too.

-Jayme

On Fri, Apr 18, 2008 at 5:56 PM, John L. (IRONRUBY)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Brian\_Blackwell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@Brian\_Blackwell](https://www.ruby-forum.com/u/Brian_Blackwell)\
**Post date:** [May 22, 2008, 6:20am UTC](https://www.ruby-forum.com/t/running-activerecord/135185/5 "2008-05-22T06:20:16Z")

</div>

Hi John,

No worries - see the attached zip file which contains the Ruby SQLite3  
driver with a couple of minor modifications (in particular the modified  
database.rb loads the [ADO.NET](http://ADO.NET) wrapper instead of the native driver). The  
[ADO.NET](http://ADO.NET) wrapper itself can be found in the directory  
‘sqlite3\driver\ironruby’. Although it is still very much a prototype, I  
have been able to get a simple activerecord use case up and running  
(with a few workarounds for remaining IronRuby bugs) which creates  
tables and performs queries. The required SQLite3 [ADO.NET](http://ADO.NET) DLL can be  
found at [http://sqlite.phxsoftware.com](http://sqlite.phxsoftware.com).

Cheers,  
Brian

On Wed, 21 May 2008 15:30:38 -0700, “John L. (IRONRUBY)”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) said:

---

<div class="post-metadata">

**Author:** ![Brian\_Blackwell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c4cdca/32.png) [@Brian\_Blackwell](https://www.ruby-forum.com/u/Brian_Blackwell)\
**Post date:** [May 22, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/running-activerecord/135185/6 "2008-05-22T20:28:30Z")

</div>

Brian Blackwell:

> No worries - see the attached zip file which contains the Ruby SQLite3  
> driver with a couple of minor modifications (in particular the  
> modified database.rb loads the [ADO.NET](http://ADO.NET) wrapper instead of the native driver).  
> The [ADO.NET](http://ADO.NET) wrapper itself can be found in the directory  
> ‘sqlite3\driver\ironruby’. Although it is still very much a prototype,  
> I have been able to get a simple activerecord use case up and running  
> (with a few workarounds for remaining IronRuby bugs) which creates  
> tables and performs queries. The required SQLite3 [ADO.NET](http://ADO.NET) DLL can be  
> found at [http://sqlite.phxsoftware.com](http://sqlite.phxsoftware.com).

Cool. Thanks!  
-John
