Making a Website with Ruby (not rails?)

J

Jesse Jurman

I have been programming in Ruby for a while and have made several
personal applications, so I'd like to say I'm not a complete novice when
it comes to Ruby, and programming in general; however I have not gone as
far as the complexities involved in Ruby on Rails (it's more or less the
multiple class/files setup).

I want to make a website with Ruby for a group I'm in, nothing
complicated (no forums or accounts), and while this is suppose to be a
simple read-only type website, whenever I look for making websites with
Ruby, I'm always redirected to a Ruby on Rails page. Is this something
that can be done with just Ruby, or would I be better off to learn Ruby
on Rails?

Any tutorials, tips, or links would be greatly appreciated.

-JRJurman
 
D

Dhruva Sagar

[Note: parts of this message were removed to make it a legal post.]

+1 for Sinatra, it is damn easy to use and get started with, the source of
sinatra isn't very long either, you can actually read it and understand it
yourself.
 
S

Stu

I have been programming in Ruby for a while and have made several
personal applications, so I'd like to say I'm not a complete novice when
it comes to Ruby, and programming in general; however I have not gone as
far as the complexities involved in Ruby on Rails (it's more or less the
multiple class/files setup).

I want to make a website with Ruby for a group I'm in, nothing
complicated (no forums or accounts), and while this is suppose to be a
simple read-only type website, whenever I look for making websites with
Ruby, I'm always redirected to a Ruby on Rails page. Is this something
that can be done with just Ruby, or would I be better off to learn Ruby
on Rails?

Any tutorials, tips, or links would be greatly appreciated.

-JRJurman

This one looks interesting:

http://ramaze.net/learn/getting-started
 
R

Rainer Frey

Jesse said:
I want to make a website with Ruby for a group I'm in, nothing
complicated (no forums or accounts), and while this is suppose to be a
simple read-only type website,

What part or aspect of the web site do you want to do in ruby then?

Rainer
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

I have been programming in Ruby for a while and have made several
personal applications, so I'd like to say I'm not a complete novice when
it comes to Ruby, and programming in general; however I have not gone as
far as the complexities involved in Ruby on Rails (it's more or less the
multiple class/files setup).

I want to make a website with Ruby for a group I'm in, nothing
complicated (no forums or accounts), and while this is suppose to be a
simple read-only type website, whenever I look for making websites with
Ruby, I'm always redirected to a Ruby on Rails page. Is this something
that can be done with just Ruby, or would I be better off to learn Ruby
on Rails?

Any tutorials, tips, or links would be greatly appreciated.

-JRJurman
It sounds like you just want a static site (content doesn't change), with
simple pages that you serve up to the user? If so, the simplest way to do it
is just write it with HTML.

-------------------------

A step up from there would be to generate the pages with ERB, this would
allow you to do some calculations in the page at the time you compile them
to HTML. For example:

require 'erb'
template = <<-HTML
<ul>
<% ('a'..'z').each do |char| %>
<li><%= char %></li>
<% end %>
</ul>
HTML
puts ERB.new(template,nil,'>').result

-------------------------

A step up from there would be to go to a static site framework, here is a
pretty good list:
http://ruby-toolbox.com/categories/static_website_generation.html

-------------------------

A step up from there would be a simple dynamic website, probably with a
database. I'd suggest Sinatra, and the Sinatra screencast from Peepcode
shows a good example.

-------------------------

And of course, you'll need to host it somewhere. Heroku is fast and easy for
this sort of thing (though you need to know git -- or at least how to add ,
commit , and push) For a static site, you will want this hierarchy:

|-- config.ru
`-- public
|-- file1.html
`-- index.html

Where "public" contains your static html files that you want to serve up,
and "config.ru" has the contents:

run lambda { |env|
if env['PATH_INFO'] == '/'
[301, { 'Location' => '/index.html' , 'Content-Type' => 'text/html' },
[''] ]
else
Rack::File.new(File.dirname(__FILE__)+"/public").call(env)
end
}

-------------------------

Final thoughts: I'm going to recommend against serving Sinatra on Heroku,
you have to know what you're doing and be able to go digging through their
source code to troubleshoot errors stemming from not using Rails. For that,
you might look into Engine Yard, I haven't used them, but they repeatedly
impress me, and are supposed to be willing to work with you if you need it.

If your site is more than trivially dynamic, I think Rails is better than
Sinatra. I worked on a moderately sized Sinatra project where quite a bit of
time was spent dealing with not having the niceties of Rails accessible.

If this is your first dynamic site, and you are debating between Sinatra and
Rails, go with Sinatra. You will be overwhelmed with Rails, but Sinatra is
pretty easy to grok. It also will get you comfortable enough with the
concepts that Rails will be much easier for you afterward.
 
M

Mike Stephens

Horse for courses. Pick something like Joomla, or if the content doesn't
change much, just draw it with something like Xara Web.
 
S

Steve Klabnik

[Note: parts of this message were removed to make it a legal post.]
Final thoughts: I'm going to recommend against serving Sinatra on Heroku,
you have to know what you're doing and be able to go digging through their
source code to troubleshoot errors stemming from not using Rails.



Have you tried hosting Sinatra on Heroku? This simply isn't true.
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

Have you tried hosting Sinatra on Heroku? This simply isn't true.

Yes, I have. I did have to go looking through the Heroku gem maybe 2 or 3
times. It is simple things that you would not think about, like your
database.yaml file must be in a folder named config, in your project root,
and the keys in that file must be strings, not symbols. Whoops, even that
isn't right, it must end in yml, not in yaml. You don't have to think about
that in Rails, Rails just does that, but in not Rails, you need to know.
 
S

Steve Klabnik

[Note: parts of this message were removed to make it a legal post.]

Interesting. I have half a dozen Sinatra projects on Heroku, and I never had
to deal with any of those issues. I guess I just got lucky with my config
setup...
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

Interesting. I have half a dozen Sinatra projects on Heroku, and I never
had
to deal with any of those issues. I guess I just got lucky with my config
setup...

You probably were smarter about it than I was. I followed some Rails
conventions where they made sense, and digressed where it seemed appropriate
or where I wasn't checking to see how Rails had done it. Those digressions
were a mistake, and I think I regretted almost all of them. I looked at the
heroku code now, and it looks like it is much friendlier about explaining to
you why whatever you were trying to do didn't work, but it used to silently
rescue exceptions and just not work, or fail somewhere else further on, so I
had to load up the gem, and follow it down from the binary to see where it
was going wrong.
 
J

Jesse Jurman

Thanks for the responses, I really just want to avoid using HTML, as I
have had trouble both setting it up file wise, as well as graphics wise.
I'm glad there are a multitude of different solutions involving ruby,
and I'll defiantly check them out later today!
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top