Ruby without rails?

I'm trying to develop a small website, and was planning to use Ruby
alone (I don't know much Rails, and wasn't planning on learning it for
the project). Is there a way to run .rb files under a webserver. I'm
developing the site on Windows and will eventually be running it on a
unix platform with Apache. I tried using instantrails, but that didn't
help. I even installed the fast-cgi module in Apache. When I run the .rb
file, I simple see the code. This is the code I'm trying to run -

print <<-HTMLEND
  <html>
    <head>
      <title>Hello World</title>
    </head>
    <body>
      <h1>Hello World</h1>
    </body>
  </html>
HTMLEND

···

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

If your intention is to generate static pages then I would recommend webby <http://webby.rubyforge.org> or one of the other static website generators written in ruby (nanoc, webgen, rassmalog).

If you are going to connect to a database and serve dynamic content, then you could look into some of the rails alternatives: merb, ramaze, iowa, camping.

Blessings,
TwP

···

On Jul 8, 2008, at 10:23 AM, Shashank Agarwal wrote:

I'm trying to develop a small website, and was planning to use Ruby
alone (I don't know much Rails, and wasn't planning on learning it for
the project). Is there a way to run .rb files under a webserver. I'm
developing the site on Windows and will eventually be running it on a
unix platform with Apache. I tried using instantrails, but that didn't
help. I even installed the fast-cgi module in Apache. When I run the .rb
file, I simple see the code. This is the code I'm trying to run -

print <<-HTMLEND
<html>
   <head>
     <title>Hello World</title>
   </head>
   <body>
     <h1>Hello World</h1>
   </body>
</html>
HTMLEND

The simplest thing to do is use one of the (many excellent)
microframeworks out there. (I can personally recommend ramaze, and
sinatra looks excellent too). But to answer your original question,
take a look at http://coolnamehere.com/geekery/ruby/web/cgi.html -
your script needs to be executable, registered with your webserver as
a cgi handler, and emit the proper headers. As your app gets more
complicated, you'll probably need to handle CGI forms, redirects, etc,
all of which is a nuisance, which is why I recommend using a
microframework.

martin

···

On Tue, Jul 8, 2008 at 9:23 AM, Shashank Agarwal <shashank_hi@yahoo.com> wrote:

I'm trying to develop a small website, and was planning to use Ruby
alone (I don't know much Rails, and wasn't planning on learning it for
the project). Is there a way to run .rb files under a webserver.

Shashank Agarwal wrote:

I'm trying to develop a small website, and was planning to use Ruby
alone (I don't know much Rails, and wasn't planning on learning it for
the project). Is there a way to run .rb files under a webserver. I'm
developing the site on Windows and will eventually be running it on a
unix platform with Apache. I tried using instantrails, but that didn't
help. I even installed the fast-cgi module in Apache. When I run the .rb
file, I simple see the code. This is the code I'm trying to run -

print <<-HTMLEND
  <html>
    <head>
      <title>Hello World</title>
    </head>
    <body>
      <h1>Hello World</h1>
    </body>
  </html>
HTMLEND
  

There are quite a few ways to do web apps without rails.
Check out Camping, Ramaze or Merb, they are all alternatives to Rails as in they are WebApp frameworks.
Now, development would be done with the built in ruby webservers (WebRick, Mongrel, Thin) and deployment is a much documented subject (i.e. Ramaze in it's site has a whole bunch of deployment possibilities, including Apache).
I would definitely take the time to learn any one of them, as otherwise you *will* be reinventing the wheel for a lot of what you are going to do.
Cheers,
V.-

···

--
http://www.braveworld.net/riva

What the OP is probably looking for is something more like the way PHP is inlined.
At the very least, you will want to look at the Ruby CGI library (not well documented) and some form of eRuby, ERB or Erubis or something similar.

···

On Jul 8, 2008, at 11:39 AM, Vassilis Rizopoulos wrote:

Shashank Agarwal wrote:

I'm trying to develop a small website, and was planning to use Ruby
alone (I don't know much Rails, and wasn't planning on learning it for
the project). Is there a way to run .rb files under a webserver. I'm
developing the site on Windows and will eventually be running it on a
unix platform with Apache. I tried using instantrails, but that didn't
help. I even installed the fast-cgi module in Apache. When I run the .rb
file, I simple see the code. This is the code I'm trying to run -

print <<-HTMLEND
<html>
   <head>
     <title>Hello World</title>
   </head>
   <body>
     <h1>Hello World</h1>
   </body>
</html>
HTMLEND

There are quite a few ways to do web apps without rails.
Check out Camping, Ramaze or Merb, they are all alternatives to Rails as in they are WebApp frameworks.
Now, development would be done with the built in ruby webservers (WebRick, Mongrel, Thin) and deployment is a much documented subject (i.e. Ramaze in it's site has a whole bunch of deployment possibilities, including Apache).
I would definitely take the time to learn any one of them, as otherwise you *will* be reinventing the wheel for a lot of what you are going to do.
Cheers,
V.-

--
http://www.braveworld.net/riva

Tim Pease wrote:

If your intention is to generate static pages then I would recommend webby <http://webby.rubyforge.org> or one of the other static website generators written in ruby (nanoc, webgen, rassmalog).

I second that. Webby is quite cool.

If you are going to connect to a database and serve dynamic content, then you could look into some of the rails alternatives: merb, ramaze, iowa, camping.

Also quite true. There are several Ruby Web frameworks that, like Ruby, are light yet powerful; migrating from a Webby site to a Ramaze site (should you decide you need a DB back-end) would be trivial.

···

--
James Britt

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff

Thank you all for the wonderful suggestions. :). I've started looking
into Ramaze, and it definitely seems more manageable than Rails. I need
to connect to a database, so Webby went out, while I couldn't find a
good tutorial for Merb. I looked at Ramaze's screenshots and it
certainly seemed something that I could handle. But thank you once
again. I was very lost before this (and even thought of using PHP once
(phew)). :slight_smile:

···

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

John Joyce wrote:

What the OP is probably looking for is something more like the way PHP is inlined.
At the very least, you will want to look at the Ruby CGI library (not well documented) and some form of eRuby, ERB or Erubis or something similar.

Or Ramaze or (I think) Merb, which easily allow you do create 1-file PHP-sort-of-but-thankfully-not-really Web apps.

···

--
James Britt

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff

Shashank Agarwal wrote:

I looked at Ramaze's screenshots

Whoops, I meant screencasts

···

--
Posted via http://www.ruby-forum.com/\.

Ramaze is an excellent choice. You could also check out my little
framework called Vintage that's very PHP-esque except in Ruby. I
don't have database stuff "in the framework" but you can set it up and
still use it inside of it.

--Jeremy

···

On Tue, Jul 8, 2008 at 2:02 PM, Shashank Agarwal <shashank_hi@yahoo.com> wrote:

Thank you all for the wonderful suggestions. :). I've started looking
into Ramaze, and it definitely seems more manageable than Rails. I need
to connect to a database, so Webby went out, while I couldn't find a
good tutorial for Merb. I looked at Ramaze's screenshots and it
certainly seemed something that I could handle. But thank you once
again. I was very lost before this (and even thought of using PHP once
(phew)). :slight_smile:
--
Posted via http://www.ruby-forum.com/\.

--
http://jeremymcanally.com/
http://entp.com

Read my books:
Ruby in Practice (http://manning.com/mcanally/\)
My free Ruby e-book (http://humblelittlerubybook.com/\)

Or, my blogs:

http://rubyinpractice.com

Shashank Agarwal wrote:

Thank you all for the wonderful suggestions. :). I've started looking into Ramaze, and it definitely seems more manageable than Rails. I need to connect to a database, so Webby went out, while I couldn't find a good tutorial for Merb. I looked at Ramaze's screenshots and it certainly seemed something that I could handle. But thank you once again. I was very lost before this (and even thought of using PHP once (phew)). :slight_smile:

Drop by the #ramaze IRC channel on freenode; it's usually quite active and folks are quick to help.

···

--
James Britt

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff