Ruby without rails?

  • Thread starter Shashank Agarwal
  • Start date
S

Shashank Agarwal

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
 
T

Tim Pease

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

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
 
M

Martin DeMello

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.

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
 
V

Vassilis Rizopoulos

Shashank said:
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.-
 
J

John Joyce

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.-
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.
 
J

James Britt

Tim said:
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
 
J

James Britt

John said:
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
 
S

Shashank Agarwal

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)). :)
 
J

Jeremy McAnally

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

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)). :)



--
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://mrneighborly.com
http://rubyinpractice.com
 
J

James Britt

Shashank said:
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)). :)


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top