From: Brian Candler Date: 2011-01-27T16:02:05+09:00 Subject: Re: rhtml and apache trouble Mitul Ti wrote in post #977720: > I am trying to run embedded ruby inside rhtml. > > $cat test.rhtml > > <% print "Content-type: text/html\n\n" %> One problem is that you must not output a blank line before the HTTP headers. That will give the Apache error you saw, at least it does with CGI scripts. (Having said that, I'm not 100% sure that rhtml files should generate HTTP headers in the first place) A second problem is that I don't think you should use 'print' inside rhtml. Use <%= ... %> instead. $cat test.rhtml Content-Type: text/html Testing <% foo = "Ruby" %> <%= "#{foo}!" %> > AddType application/x-httpd-eruby .rhtml > Action application/x-httpd-eruby Dir/cgi-bin/eruby Have you installed a copy of eruby inside your cgi-bin directory in that location? Is it executable? To be honest, I think you'll find almost nobody uses ruby this way any more, because it gives you the worst of all worlds: the inefficiency of cgi-bin (forking a new ruby interpreter for every request) with the PHP-like muddle of mixing your application logic inside your HTML templates. You should probably look at writing an application using a simple framework like Sinatra, which is just a layer on top of Rack. For development you can run it as a standalone webserver on its own port. For production you can either run it inside Apache using Phusion Passenger, or you can run a pool of mongrel/thin/unicorn/rainbows! webservers and proxy to them. -- Posted via http://www.ruby-forum.com/.