[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

eRuby/erb outside of Rails

Jonny Noog

11/28/2008 12:10:00 AM

Hello,

I am currently working on planning for the redevelopment of a website.
This website will be mainly static, the only dynamic functionality that
I am envisioning is some server-side includes to make maintenance
easier, perhaps a form or two that sends an email etc. No database
backend at this stage.

I could very easily use straight up PHP to give me this kind of basic
functionality, but I prefer Ruby and in this case, I think Rails might
be a bit heavy for what I am looking at. So I'm thinking about
eRuby/erb.

I have read about mod_ruby and mod_rails. Some sources seem to suggest
that mod_ruby "has never really worked properly", while others seem to
suggest otherwise. I have not been able to ascertain whether mod_rails
would allow the use of eRuby/erb without Rails to go with it.

So my questions are: Does anyone have any experience with a set up that
allows embedded Ruby to be interpreted and served performantly and
reliably in (X)HTML pages (say under the .rhtml extension) in much the
same way that mod_php does with .php files (I gather this is what
mod_ruby is meant to do, but I have read many mixed reviews)? And does
mod_rails/mod_rack hold any promise in this regard?

Ideally a solution that would allow embedding and serving of .rhtml
files outside of a Rails app but also allow the deployment of a full
Rails app, say in a sub-domain or something would be awesome, but I'm
happy to take it one step at a time.
--
Posted via http://www.ruby-....

16 Answers

Post Tudbc

11/28/2008 1:40:00 AM

0

Try the free tool TudbcJRubyServlet

http://www.tudbc.org/tudbcjr...

which is backed by the robustness of any Java EE Servers (e.g.
GlassFish, Tomcat, Resin, etc.)

Jonny Noog wrote:
> Hello,
>
> I am currently working on planning for the redevelopment of a website.
> This website will be mainly static, the only dynamic functionality that
> I am envisioning is some server-side includes to make maintenance
> easier, perhaps a form or two that sends an email etc. No database
> backend at this stage.
>
> I could very easily use straight up PHP to give me this kind of basic
> functionality, but I prefer Ruby and in this case, I think Rails might
> be a bit heavy for what I am looking at. So I'm thinking about
> eRuby/erb.
>
> I have read about mod_ruby and mod_rails. Some sources seem to suggest
> that mod_ruby "has never really worked properly", while others seem to
> suggest otherwise. I have not been able to ascertain whether mod_rails
> would allow the use of eRuby/erb without Rails to go with it.
>
> So my questions are: Does anyone have any experience with a set up that
> allows embedded Ruby to be interpreted and served performantly and
> reliably in (X)HTML pages (say under the .rhtml extension) in much the
> same way that mod_php does with .php files (I gather this is what
> mod_ruby is meant to do, but I have read many mixed reviews)? And does
> mod_rails/mod_rack hold any promise in this regard?
>
> Ideally a solution that would allow embedding and serving of .rhtml
> files outside of a Rails app but also allow the deployment of a full
> Rails app, say in a sub-domain or something would be awesome, but I'm
> happy to take it one step at a time.

--
Posted via http://www.ruby-....

Rob Biedenharn

11/28/2008 2:17:00 AM

0


On Nov 27, 2008, at 7:10 PM, Jonny Noog wrote:

> Hello,
>
> I am currently working on planning for the redevelopment of a website.
> This website will be mainly static, the only dynamic functionality
> that
> I am envisioning is some server-side includes to make maintenance
> easier, perhaps a form or two that sends an email etc. No database
> backend at this stage.
>
> I could very easily use straight up PHP to give me this kind of basic
> functionality, but I prefer Ruby and in this case, I think Rails might
> be a bit heavy for what I am looking at. So I'm thinking about
> eRuby/erb.
>
> I have read about mod_ruby and mod_rails. Some sources seem to suggest
> that mod_ruby "has never really worked properly", while others seem to
> suggest otherwise. I have not been able to ascertain whether mod_rails
> would allow the use of eRuby/erb without Rails to go with it.
>
> So my questions are: Does anyone have any experience with a set up
> that
> allows embedded Ruby to be interpreted and served performantly and
> reliably in (X)HTML pages (say under the .rhtml extension) in much the
> same way that mod_php does with .php files (I gather this is what
> mod_ruby is meant to do, but I have read many mixed reviews)? And does
> mod_rails/mod_rack hold any promise in this regard?
>
> Ideally a solution that would allow embedding and serving of .rhtml
> files outside of a Rails app but also allow the deployment of a full
> Rails app, say in a sub-domain or something would be awesome, but I'm
> happy to take it one step at a time.
> --
> Posted via http://www.ruby-....

It definitely depends on your hosting environment. On Joyent, it's as
simple as having:

$ cat web/public/.htaccess
Action eruby-script /cgi-bin/eruby
AddHandler eruby-script .rhtml

And then and file with an .rhtml extension will be run through eruby.

-Rob

Rob Biedenharn http://agileconsult...
Rob@AgileConsultingLLC.com


Jonny Noog

11/28/2008 3:02:00 AM

0

Post Tudbc wrote:
> Try the free tool TudbcJRubyServlet
>
> http://www.tudbc.org/tudbcjr...
>
> which is backed by the robustness of any Java EE Servers (e.g.
> GlassFish, Tomcat, Resin, etc.)

Thanks for the suggestion. From reading a bit on your site, it sounds
really cool. But honestly, I'm not sure if my current knowledge would be
up to a trip through the Java world. I've never had any exposure to
JRuby or Tomcat or really anything directly related to Java. How
involved is setting up and using JRuby + Tomcat + tudbcjrubyservlet +
Rails or erb compared to say, MRI + apache + mongrel + Rails (which I do
have experience with)?


Rob Biedenharn wrote:
> On Nov 27, 2008, at 7:10 PM, Jonny Noog wrote:
>
>> functionality, but I prefer Ruby and in this case, I think Rails might
>> allows embedded Ruby to be interpreted and served performantly and
>> Posted via http://www.ruby-....
> It definitely depends on your hosting environment. On Joyent, it's as
> simple as having:
>
> $ cat web/public/.htaccess
> Action eruby-script /cgi-bin/eruby
> AddHandler eruby-script .rhtml
>
> And then and file with an .rhtml extension will be run through eruby.
>
> -Rob

Hmm, well it's likely that this website (plus a few others) will be
running on a Linux VPS (probably CentOS). So I can pretty much to what I
want with it. It's really down to how much time and effort it will take
to get stuff set up and working the way I want. The VPS will no doubt
already come with PHP/apache/MySQL already installed and configured, but
I was really hoping that there is a relatively easy way for me to:

a) Get some reliable standalone embedded Ruby action happening now (a la
mod_php).

b) Allow for the use of Rails in the future.

But if things begin to look too involved, then I may just take the
pragmatic appraoch and stick to PHP for now.
--
Posted via http://www.ruby-....

Post Tudbc

11/28/2008 4:09:00 AM

0

Jonny Noog wrote:
> Post Tudbc wrote:
>> Try the free tool TudbcJRubyServlet
>>
>> http://www.tudbc.org/tudbcjr...
>>
>> which is backed by the robustness of any Java EE Servers (e.g.
>> GlassFish, Tomcat, Resin, etc.)
>
> Thanks for the suggestion. From reading a bit on your site, it sounds
> really cool. But honestly, I'm not sure if my current knowledge would be
> up to a trip through the Java world. I've never had any exposure to
> JRuby or Tomcat or really anything directly related to Java. How
> involved is setting up and using JRuby + Tomcat + tudbcjrubyservlet +
> Rails or erb compared to say, MRI + apache + mongrel + Rails (which I do
> have experience with)?

The setup is simple (see the web site for step-by-step instruction),
basically: Java JDK, Tomcat, JRuby, and TudbcJRubyServlet. After that
you don't even need to know anything about Java or Tomcat. You just need
to know Ruby (note: JRuby is a pure Ruby implementation). You can look
at the live demos, and they are all pure Ruby codes.

Best of all, it is much faster (sometimes many times faster, see
http://www.tudbc.org/j... for comparisons) and more realiable.

Later on, if you like the Java EE environment, there is also Quercus
which is a Java port of PHP.
--
Posted via http://www.ruby-....

Jonny Noog

11/28/2008 4:22:00 AM

0

Post Tudbc wrote:
> The setup is simple (see the web site for step-by-step instruction),
> basically: Java JDK, Tomcat, JRuby, and TudbcJRubyServlet. After that
> you don't even need to know anything about Java or Tomcat. You just need
> to know Ruby (note: JRuby is a pure Ruby implementation). You can look
> at the live demos, and they are all pure Ruby codes.
>
> Best of all, it is much faster (sometimes many times faster, see
> http://www.tudbc.org/j... for comparisons) and more realiable.
>
> Later on, if you like the Java EE environment, there is also Quercus
> which is a Java port of PHP.

Well, that certainly sounds very tempting. :)

I will have to look into it further. Thanks.

--
Posted via http://www.ruby-....

Dick Davies

11/28/2008 10:12:00 AM

0

Why would you use this rather than Warbler (for example)?

On Fri, Nov 28, 2008 at 1:39 AM, Post Tudbc <post@tudbc.org> wrote:
> Try the free tool TudbcJRubyServlet
>
> http://www.tudbc.org/tudbcjr...
>
> which is backed by the robustness of any Java EE Servers (e.g.
> GlassFish, Tomcat, Resin, etc.)
>
> Jonny Noog wrote:
>> Hello,
>>
>> I am currently working on planning for the redevelopment of a website.
>> This website will be mainly static, the only dynamic functionality that
>> I am envisioning is some server-side includes to make maintenance
>> easier, perhaps a form or two that sends an email etc. No database
>> backend at this stage.
>>
>> I could very easily use straight up PHP to give me this kind of basic
>> functionality, but I prefer Ruby and in this case, I think Rails might
>> be a bit heavy for what I am looking at. So I'm thinking about
>> eRuby/erb.
>>
>> I have read about mod_ruby and mod_rails. Some sources seem to suggest
>> that mod_ruby "has never really worked properly", while others seem to
>> suggest otherwise. I have not been able to ascertain whether mod_rails
>> would allow the use of eRuby/erb without Rails to go with it.
>>
>> So my questions are: Does anyone have any experience with a set up that
>> allows embedded Ruby to be interpreted and served performantly and
>> reliably in (X)HTML pages (say under the .rhtml extension) in much the
>> same way that mod_php does with .php files (I gather this is what
>> mod_ruby is meant to do, but I have read many mixed reviews)? And does
>> mod_rails/mod_rack hold any promise in this regard?
>>
>> Ideally a solution that would allow embedding and serving of .rhtml
>> files outside of a Rails app but also allow the deployment of a full
>> Rails app, say in a sub-domain or something would be awesome, but I'm
>> happy to take it one step at a time.
>
> --
> Posted via http://www.ruby-....
>
>

Brian Candler

11/28/2008 1:19:00 PM

0

Jonny Noog wrote:
> I have read about mod_ruby and mod_rails. Some sources seem to suggest
> that mod_ruby "has never really worked properly", while others seem to
> suggest otherwise. I have not been able to ascertain whether mod_rails
> would allow the use of eRuby/erb without Rails to go with it.

Also have a look at erubis: http://www.kuwata-lab.c...

Now, the /cgi-bin/eruby approach mentioned above is one to get you
started; but you'll be spawning a new ruby interpreter for each request.

If that becomes painful, and you don't fancy mod_ruby, then I suggest
FastCGI as the way to go (with mod_fcgid). I don't know if either eruby
or erubis has out-of-the-box FastCGI support, but it shouldn't be too
hard to make a wrapper which reads the template and expands it, in a
loop. With a bit of mtime checking you could even cache the parsed
templates.

Regards,

Brian.
--
Posted via http://www.ruby-....

Post Tudbc

11/29/2008 2:00:00 AM

0

Dick Davies wrote:
> Why would you use this rather than Warbler (for example)?

Because it is really simple to use. You can create a simple webapp to do
an addition x+y with just one line of codes:

------------add.rb--------------------
ctx.print(ctx.getParam('x').to_f + ctx.getParam('y').to_f)
--------------------------------------

------------add.erb--------------------
<%= ctx.getParam('x').to_f + ctx.getParam('y').to_f %>
---------------------------------------

then invoke it by
http://..../add.rb?x=2&y=3
http://..../add.erb?x=2&y=3

I just added these two examples on
http://services.tudbc.com/tudbc/TudbcJRubyServletDemo/demo...

You can try it yourself.

All you need to do is to create the .rb or .erb files. And you're ready
to go. No more setup, no more warbler, or deploying.
--
Posted via http://www.ruby-....

Jonny Noog

11/30/2008 10:07:00 PM

0

I appreciate the further suggestions and comments. Thanks very much. :)
--
Posted via http://www.ruby-....

Cyrus Broka

12/3/2008 9:20:00 PM

0

Jonny Noog wrote:
> I appreciate the further suggestions and comments. Thanks very much. :)

Have you checked out sinatra @ http://sinatra.ruby...
--
Posted via http://www.ruby-....