Using Rails' ActiveRecord from Groovy?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Using Rails' ActiveRecord from Groovy?

John Wells-2
Guys,

We have a good sized Rails application at our company that is in need of an admin interface. One of the requirements is that the admin interface be GUI and fat as opposed to a web client.

Since I've been wanting to spend more time with both, my choice is to either use Groovy or JRuby. And, I'm the decision maker for the company, so I have the leverage to choose my toys ;)

JRuby would seem to have an edge in this case, as it already supports ActiveRecord and "should" be able to read my AR files let me use the AR model classes for database access. However, I've more experience with JRuby than Groovy at this point, and I'd like to give Groovy a fighting chance.

Since the discussions always hover on interoperability with the JVM, I might as well ask...would there be a way to load the AR relationships via JRuby, and then call into them as if they were normal Java classes from Groovy?

If not, is there another way to skin this that I'm missing?

Thanks,
John

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Using Rails' ActiveRecord from Groovy?

Charles Oliver Nutter-2
John Wells wrote:

> Guys,
>
> We have a good sized Rails application at our company that is in need of an admin interface. One of the requirements is that the admin interface be GUI and fat as opposed to a web client.
>
> Since I've been wanting to spend more time with both, my choice is to either use Groovy or JRuby. And, I'm the decision maker for the company, so I have the leverage to choose my toys ;)
>
> JRuby would seem to have an edge in this case, as it already supports ActiveRecord and "should" be able to read my AR files let me use the AR model classes for database access. However, I've more experience with JRuby than Groovy at this point, and I'd like to give Groovy a fighting chance.
>
> Since the discussions always hover on interoperability with the JVM, I might as well ask...would there be a way to load the AR relationships via JRuby, and then call into them as if they were normal Java classes from Groovy?
>
> If not, is there another way to skin this that I'm missing?

Unfortunately, no...AR's models are generated on startup, based on the
database schema. And because they're dynamically generated they can't be
represented as static Java classes/interfaces. However you're right
about AR working in JRuby...there's been a lot of work to enure Rails
"just works", and for most common databases it's quite solid.

Also, this might be helpful:

"JRuby: Calling Ruby’s ActiveRecord from Java Using the Bean Scripting
Framework"
http://www.digitalsanctum.com/2007/07/25/calling-rubys-activerecord-from-java-using-the-bean-scripting-framework/

He uses BSF, but it should be neatly applicable to hooking up JRuby
directly or calling through javax.scripting too. And if you can do this
from Java you can obviously do it from Groovy. And there are other
examples out there.

In general, I think we're looking for input from folks about how to make
Ruby code more easily usable from other languages, especially libraries
like ActiveRecord. Because Ruby is so dynamic, we almost never can
generate static Java types a Java program could access, so most cases
require some sort of explicit contract (like an interface) you can then
access.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Using Rails' ActiveRecord from Groovy?

graemer
In reply to this post by John Wells-2
Regarding ActiveRecord and JRuby from Groovy - I doubt it as they're
not Java classes, Groovy doesn't understand them and since Groovy and
JRuby have differing MOPs you would have to jump through hoops to get
it to work

Regarding Alternatives - http://grails.org/GORM

Cheers

On 8/6/07, John Wells <[hidden email]> wrote:

> Guys,
>
> We have a good sized Rails application at our company that is in need of an admin interface. One of the requirements is that the admin interface be GUI and fat as opposed to a web client.
>
> Since I've been wanting to spend more time with both, my choice is to either use Groovy or JRuby. And, I'm the decision maker for the company, so I have the leverage to choose my toys ;)
>
> JRuby would seem to have an edge in this case, as it already supports ActiveRecord and "should" be able to read my AR files let me use the AR model classes for database access. However, I've more experience with JRuby than Groovy at this point, and I'd like to give Groovy a fighting chance.
>
> Since the discussions always hover on interoperability with the JVM, I might as well ask...would there be a way to load the AR relationships via JRuby, and then call into them as if they were normal Java classes from Groovy?
>
> If not, is there another way to skin this that I'm missing?
>
> Thanks,
> John
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Using Rails' ActiveRecord from Groovy?

Guillaume Laforge
Administrator
In reply to this post by John Wells-2
You access the database directly from the GUI?

It is possible to use Grails GORM stand-alone.
Which means you could reverse engineer the schema with Hibernate
tools, reinject that into GORM, and use all the GORM goodness in your
GUI app.

On 8/6/07, John Wells <[hidden email]> wrote:

> Guys,
>
> We have a good sized Rails application at our company that is in need of an admin interface. One of the requirements is that the admin interface be GUI and fat as opposed to a web client.
>
> Since I've been wanting to spend more time with both, my choice is to either use Groovy or JRuby. And, I'm the decision maker for the company, so I have the leverage to choose my toys ;)
>
> JRuby would seem to have an edge in this case, as it already supports ActiveRecord and "should" be able to read my AR files let me use the AR model classes for database access. However, I've more experience with JRuby than Groovy at this point, and I'd like to give Groovy a fighting chance.
>
> Since the discussions always hover on interoperability with the JVM, I might as well ask...would there be a way to load the AR relationships via JRuby, and then call into them as if they were normal Java classes from Groovy?
>
> If not, is there another way to skin this that I'm missing?
>
> Thanks,
> John
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Using Rails' ActiveRecord from Groovy?

Charles Oliver Nutter-2
In reply to this post by John Wells-2
John Wells wrote:

> Guys,
>
> We have a good sized Rails application at our company that is in need of an admin interface. One of the requirements is that the admin interface be GUI and fat as opposed to a web client.
>
> Since I've been wanting to spend more time with both, my choice is to either use Groovy or JRuby. And, I'm the decision maker for the company, so I have the leverage to choose my toys ;)
>
> JRuby would seem to have an edge in this case, as it already supports ActiveRecord and "should" be able to read my AR files let me use the AR model classes for database access. However, I've more experience with JRuby than Groovy at this point, and I'd like to give Groovy a fighting chance.
>
> Since the discussions always hover on interoperability with the JVM, I might as well ask...would there be a way to load the AR relationships via JRuby, and then call into them as if they were normal Java classes from Groovy?
>
> If not, is there another way to skin this that I'm missing?

Also, not to steer you away from Groovy, but there are a number of GUI
libraries for JRuby that make it pretty easy. Two of note:

Cheri (a SwingBuilder-like clone with bean binding):
http://www2.webng.com/bdortch/cheri/

Profligacy (less of a builder, but with binding and a compact layout
language):
http://ihate.rubyforge.org/profligacy/

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Using Rails' ActiveRecord from Groovy?

John Wells-2
In reply to this post by Guillaume Laforge
----- "Guillaume Laforge" <[hidden email]> wrote:
> You access the database directly from the GUI?
>
> It is possible to use Grails GORM stand-alone.
> Which means you could reverse engineer the schema with Hibernate
> tools, reinject that into GORM, and use all the GORM goodness in your
> GUI app.

Interesting...it *is* a fairly straightforward schema...can you point me to any docs on how to do this?

Thanks,
John

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Using Rails' ActiveRecord from Groovy?

John Wells-2
In reply to this post by Charles Oliver Nutter-2
----- "Charles Oliver Nutter" <[hidden email]> wrote:
> Also, not to steer you away from Groovy, but there are a number of GUI
> libraries for JRuby that make it pretty easy. Two of note:
>
> Cheri (a SwingBuilder-like clone with bean binding):
> http://www2.webng.com/bdortch/cheri/
>
> Profligacy (less of a builder, but with binding and a compact layout
> language):
> http://ihate.rubyforge.org/profligacy/

Charles,

Could you comment on the stability of both? The perception here amongst a few of my guys is that SwingBuilder (Groovy) is more mature than Cheri or Profligacy. Could be wrong, but would appreciate your insight.

Thanks,
John

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Using Rails' ActiveRecord from Groovy?

Charles Oliver Nutter-2
In reply to this post by John Wells-2
John Wells wrote:
> ----- "Guillaume Laforge" <[hidden email]> wrote:
>> You access the database directly from the GUI?
>>
>> It is possible to use Grails GORM stand-alone.
>> Which means you could reverse engineer the schema with Hibernate
>> tools, reinject that into GORM, and use all the GORM goodness in your
>> GUI app.
>
> Interesting...it *is* a fairly straightforward schema...can you point me to any docs on how to do this?

The only caution I'd offer here is that Rails development tends to play
a bit more fast and loose with the DB schema; so you have to be careful
if generating a static snapshot of an evolving database.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Using Rails' ActiveRecord from Groovy?

Guillaume Laforge
Administrator
In reply to this post by John Wells-2
For what I know, Cheri and Profligacy are brand new, while Groovy's
SwingBuilder is almost 4 years old and has seen a lot of improvements
over the time.


On 8/6/07, John Wells <[hidden email]> wrote:

> ----- "Charles Oliver Nutter" <[hidden email]> wrote:
> > Also, not to steer you away from Groovy, but there are a number of GUI
> > libraries for JRuby that make it pretty easy. Two of note:
> >
> > Cheri (a SwingBuilder-like clone with bean binding):
> > http://www2.webng.com/bdortch/cheri/
> >
> > Profligacy (less of a builder, but with binding and a compact layout
> > language):
> > http://ihate.rubyforge.org/profligacy/
>
> Charles,
>
> Could you comment on the stability of both? The perception here amongst a few of my guys is that SwingBuilder (Groovy) is more mature than Cheri or Profligacy. Could be wrong, but would appreciate your insight.
>
> Thanks,
> John
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Using Rails' ActiveRecord from Groovy?

Guillaume Laforge
Administrator
In reply to this post by John Wells-2
On 8/6/07, John Wells <[hidden email]> wrote:
> ----- "Guillaume Laforge" <[hidden email]> wrote:
> > You access the database directly from the GUI?
> >
> > It is possible to use Grails GORM stand-alone.
> > Which means you could reverse engineer the schema with Hibernate
> > tools, reinject that into GORM, and use all the GORM goodness in your
> > GUI app.
>
> Interesting...it *is* a fairly straightforward schema...can you point me to any docs on how to do this?

This link might be what you're after:
http://grails.org/GORM+-+StandAlone+Gorm

That's how you can use GORM standalone.

And there are a few other interesting links on how to map GORM to
existing schemas:
http://grails.org/Hibernate+Integration

On this last page, at the end, there are a few interesting resources
as well explaining how to do mapping with Hibernate.

I'm not sure either of these resources explain how to use Hibernate
tools for doing a reverse engineering though, but it's pretty
straightforward by reading the Hibernate documentation on that topic.

--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

12