Forum: Ruby on Rails Is there a place for java in Ruby on Rails apps?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A73f446eaaf56db0aeaa578aa373989b?d=identicon&s=25 Terry Donaghe (Guest)
on 2006-05-15 01:12
(Received via mailing list)
Hi all,

I'm asking this question from the standpoint of a developer with almost
10
years experience with Microsoft technologies, mostly doing server side
component and database work.  So, I'm not very familiar with the java
world.  Can anyon tell me how/if java development can complement Ruby on
Rails development?  I'm not interested in how java can duplicate Rails
functionality, but things like whether or not it makes sense to develop
server-side components in java to leverage in Rails apps.  Is Rails by
itself a complete solution?  Does ruby and Rails make java obsolete?
Cb610750ee94ca103aef4b2dc7b1b768?d=identicon&s=25 Nick Stuart (Guest)
on 2006-05-15 01:39
(Received via mailing list)
For some things I still find Java to be useful and easier to do things
with.
(before I get flammed) This is mainly because of the VAST amount of
libraries written in the Java world. If you have thought about, it's
probably been done. Ruby isn't quite there yet, but I'm sure it will
once
the popularity gets going.

For a practicle example, for the search process of things on a site I
did
recently was done with Java Lucene (a very well written/thoroughly
tested
framework). I was almost able to this completly with Ruby (using Ferret)
but
due to some minor niggles, was unable to.

Java still has its place. Ruby is gradually building its own place. Some
(I
agree) think Ruby's place is easier to get around and has a
better/simplier
layout.

-Nick
Bc1f15044042a165585eabe83e5ea98f?d=identicon&s=25 Diego Lapiduz (Guest)
on 2006-05-15 03:29
(Received via mailing list)
Hi,

I have 1 controller with several actions and i need to show a layout
for some actions and another one for the others.

Any ideas??

Thanks,
_______________________
Diego D. Lapiduz
www.sinai.com.ar
dlap@sinai.com.ar
55428cbf149e35dd4b65f1d019d04139?d=identicon&s=25 Matthew Palmer (Guest)
on 2006-05-15 04:21
(Received via mailing list)
On Sun, May 14, 2006 at 10:27:07PM -0300, Diego Lapiduz wrote:
> I have 1 controller with several actions and i need to show a layout
> for some actions and another one for the others.
>
> Any ideas??

There's a way to specify which layout you want to use for a particular
render.  I can't remember if it's on the render call or if there's a
include/exclude option on the layout call, but it's in the API manual --
that's how I found it when I needed it a few months ago.

- Matt
A1e50806b2412d6c45d367580449f41a?d=identicon&s=25 psc|SourceAgency (Guest)
on 2006-05-15 04:37
(Received via mailing list)
It is possible to do this with

render :layout => 'yourlayout'

- Marius
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-05-15 04:40
(Received via mailing list)
On 5/14/06, Matthew Palmer <mpalmer@hezmatt.org> wrote:
>
> - Matt
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

Here's what I do:

class MyController < ApplicationController
  layout :choose_layout

  protected
  def choose_layout
    if [ 'signup', 'register' ].include? action_name
      'application'
    else
      'owners'
    end
  end
end

Pat
F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles O Nutter (Guest)
on 2006-05-15 06:54
(Received via mailing list)
I believe Java can absolutely complement Ruby on Rails, especially when
running JRuby on Rails (which works now for the OnLamp.com "Rolling with
Rails" cookbook app). Tying in JDBC behind ActiveRecord, wiring up
existing
Java components and services, deploying Rails and J2EE apps
side-by-side.
It's a win for both camps, and it's running better and better every day.

I believe that while Java and J2EE provide very powerful services for a
deep, heavy, multi-server business tier, it still sucks royally for
anything
related to web applications. With JRuby, there's a real potential now to
run
not only independent Rails apps on the JVM, but Rails apps as the web
frontend for an entire enterprise of services, with all the management,
clustering, replication, and failover those services provide.

Getting Rails to run on JRuby was only the beginning. Figuring out how
best
to use Rails on the JVM...that's even more exciting.
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2006-05-15 07:19
(Received via mailing list)
Hi, eventhough Java has a vast number of libraries, it doesn't mean
these libraries are needed within Ruby.  Also, Java is nice but Ruby
shouldn't try to be like Java.  People tend to forget the VM came from
Smalltalk not Java.  Also, one doesn't need to or have to use Java and
J2EE for a deep, heavy, and multi-server business tier.  In short,
Ruby should simply be Ruby and this leads to success in my mind
evolved from some of the best features of GREAT languages (i.e.
Smalltalk, LISP, and so on).

-Conrad
39c5254d0a798765f37ac215fa6e0fc7?d=identicon&s=25 Curtis Spendlove (cuspendlove)
on 2006-05-15 07:50
(Received via mailing list)
Terry Donaghe wrote:
> Rails make java obsolete?
Greetings.  And welcome to the Light Side.  I'm speaking from the role
of a Microsoft (on step 5 / 12 in MCSD Anonymous) and J2EE application
programmer.  I have had some extensive experience with all this
stuff...and the wheels have been turning trying to figure it all out...

I believe that Ruby and Rails could make future development faster and
simpler.  However, there are a huge amount of java apps out there.
Hopefully they've been well written and communicate in a well-structured
manner with a database.  If you can assume these conditions, you should
be able to design and write a very decent RoR front-end to a java-backed
database quickly and get rid of your jsp stuff.  :)  I am actually
trying to determine how to do this with a large J2EE app.

For new development, I think you could do much of what J2EE apps do in
the background, on the server-side, with pure Ruby.  Then similarly use
the Rails framework for the web front-end portion.  As another person
pointed out, this could be probably be determined based on the amount of
available libraries to perform the required functionality.  Java might
be best, Ruby might be best.  (I suppose, if you wanted, you could even
use a .NET or legacy MS dev environment for this...for those S&M types
out there.)  If you had to code it from scratch, I would have to say
Ruby would have a huge advantage in my book.  Honestly you could use a
different language behind each application server / web service if you
*really* wanted to.  But...damn!  (Hope you have good mental health
insurance, you'll need it.)

Regardless, I see no reason they couldn't co-exist.  In fact someone had
asked about a traditional three-tier solution a while back.  I see J2EE
/ Ruby Application Servers as a portion of this.  If you have some
complex (or lengthy) application logic, utilize the Rails front-end to
drop an event into a monitored table and let an application server
process it, reporting progress / completion to be fed back to the
front-end.  Clean.  Fast.

Tier 1 - Database Server (Postgres / MySQL / MSSQL / etc)
Tier 2 - J2EE (JBoss / WEBSphere / etc) -or- Ruby Applications (Web
Services, perhaps)
Tier 3 - RoR (standard front-end)

However, I wouldn't always make internal Tier 3 call through Tier 2 to
hit the databases...  You *could* implement that if you were paranoid or
obsessive-compulsive...  (Or even just had standards better than
mine...)  I don't consider it worth the overhead...  And if people are
working on my systems they will damn well follow my guidelines or risk
staying late with me...and buying me dinner...  :)  Seriously though,
this is called "Agile Communications" (ok I probably just made that up)
and should be practiced regularly.  Anything the "outside world"
accesses would be accessed through a Web Service at Tier 2 so I could
control it.

I hope to have it working within the year.  :)

-Curtis
Cd2382441bbe2ec68e3bf36aea0ca2ea?d=identicon&s=25 Adam Keys (Guest)
on 2006-05-15 18:04
(Received via mailing list)
On May 15, 2006, at 12:46 AM, Curtis Spendlove wrote:
> Tier 1 - Database Server (Postgres / MySQL / MSSQL / etc)
> Tier 2 - J2EE (JBoss / WEBSphere / etc) -or- Ruby Applications (Web
> Services, perhaps)
> Tier 3 - RoR (standard front-end)

Where I'm at, we have a Whole Lot of Java code that we're not going
to dump anytime soon.  I've found that rjb[1] coupled with RMI is a
very thin solution to interop.

rjb allows me to embed a Java VM *inside* my Ruby process.  From
there I call the client side of our RMI API to talk to the rest of
our code.  I wrote a require_jvm helper to make grabbing Java classes
easier; the whole layer between Java and Ruby is about 50 lines of
code (plus the rjb extension).

If embedding a Java VM in your Ruby process feels distasteful, check
out Hessian[2].  It implements a binary RPC protocol over HTTP.
There is a Ruby gem implementing the client side of it.  I found it
was pretty easy to get going.

I highly recommend this stuff.  If anyone is interested, I can go
into further details.

[1] http://mvm.therealadam.com/articles/2006/03/26/enterprise-
integration-with-ruby-saves-my-ass
[2] http://www.caucho.com/hessian/

--
~akk
http://therealadam.com
88f69d680829d977e3585725fccea8fe?d=identicon&s=25 Guest (Guest)
on 2006-05-16 00:48
Adam Keys wrote:
>
> Where I'm at, we have a Whole Lot of Java code that we're not going
> to dump anytime soon.  I've found that rjb[1] coupled with RMI is a
> very thin solution to interop.
>
> rjb allows me to embed a Java VM *inside* my Ruby process.  From
> there I call the client side of our RMI API to talk to the rest of
> our code.  I wrote a require_jvm helper to make grabbing Java classes
> easier; the whole layer between Java and Ruby is about 50 lines of
> code (plus the rjb extension).
>

Does it means it could be quite easy to do some interaction between a
rails app and, let's say, a java search engine ?

In that case (interfacing with a search engine, I take this example
because it's easier for me to understand) what is the Java architecture
counterpart ? I hope it does not mean running a Tomcat instance just to
have access to the Java services ? Is there a 'lighter' solution ?
Cb610750ee94ca103aef4b2dc7b1b768?d=identicon&s=25 Nick Stuart (Guest)
on 2006-05-16 14:14
(Received via mailing list)
This has been discussed about before. Do a search for Lucene and/or
Ferret
and you should get some results. I've also written about my experinces
as
well:

http://blog.nicholasstuart.com/articles/2006/02/11...
8c7a98649cdbbdf39eeed17ca9bdbbd3?d=identicon&s=25 Josh Charles (Guest)
on 2006-05-16 14:33
(Received via mailing list)
I'm working on a very large Ruby on Rails application (dare I say it -
enterprisey?), but there are a few things that I needed to do in .NET.
 I know that it's not Java, but from what I understand the
technologies are similar (I've never touched Java at all).

The main thing was interacting with my organizations Active Directory.
 Instead of going through the trouble of making sure my production
linux server was part of the domain and could access the Active
directory, I just stuck a secure webservice up with the two functions
I needed and call those from my Controllers.  While not the most
beautiful solution, it does allow me to continue building things
quickly.

So in that sense, .NET really helped in building my RoR application.

Josh
This topic is locked and can not be replied to.