david2 wrote:
This is all very confusing. I’ve been googling…
It’s not really all that confusing, you’re just confusing it all.
I see references to .erb files, .rhtml and .erb.html files. Sounds
like what I want to do can be done, but I don’t get the impression its
done very often because it doesn’t seem very easy nor straightforward.
Embedded Ruby (.erb). Ruby HTML (.rhtml). The .rhtml is an older
convention that isn’t used so much in newer versions of Rails. The
rendering engine (.erb) has been separated from the template format
(.html). This eases support for handling multiple representations of
pages. For example you might have a different layout for mobile devices.
The newer convention would allow you to name the two layouts
accordingly, such as index.html.erb & index.mobile.erb. The later could
still be HTML, but formatted for mobile devices. Both still use Embedded
Ruby. There are also other engines, such as builder (index.xml.builder)
and Ruby JavaScript (index.js.rjs).
I think where you might be getting confused is that in the case of PHP
the “engine,” or “intelligence,” is wrapped up inside the Apache module.
It’s all that C code that really does the grunt work for PHP template
rendering.
I’ve found instructions where you can manually create a ruby script
and a CGI command to run whatever extension you define in an Apache
config file. Its an amazingly manual configuration process.
Does no one do this? Is it Ruby on Rails or bust? Can you use Ruby
template files, ie Ruby embedded in HTML on an Apache webserver or do
most folks just use PHP if this is needed and only use Ruby for web
applications?
You don’t seem to be listening to the earlier replies. It is by no means
Ruby on Rails or bust! There are many options ranging from the most
fundamental Rack application, through Sinatra and all the way up to
Rails.
As I said before, a lot of the “intelligence” of PHP is the Apache
module itself. This might give you a false sense that PHP is simpler
than a Ruby deployment. Maybe that’s somewhat so, but it’s also less
flexible than something like Passenger Phusion
(http://www.modrails.com/) + Rack (http://rack.rubyforge.org/). Phusion
is a web interface that connects Apache (or Nginx) to any Rack
application.
A Rack application can be as simple as:
class HelloWorld
def call(env)
[200, {“Content-Type” => “text/plain”}, [“Hello world!”]]
end
end
If you just want to render some ERB templates then (as Frederick
mentioned) Sinatra (Sinatra: README) is an excellent
choice.
Given that a lot (now most) Ruby frameworks and web servers are based on
Rack there is a lot of choice in the Ruby world. This is not a bad
thing! It allows us to scale our solutions to target specific needs.
In your situation I would strongly suggest you look at Sinatra. I’m mean
really look at it and not just glance at their home page.