Jose said:
Ok, so I will choose MySQL and Ruby. Is there a tutorial for MySQL
queries using Ruby?
Type "ruby mysql" into google. The fifth result is this:
http://www.kitebird.com/articles/ruby-mysql.html
That's writing code using the MySQL API directly.
If you prefer to go via a thin abstraction layer so that your code can
talk to other databases too, try "ruby dbi". I listed some
object-oriented APIs earlier.
If all I want was just to have a simple place to read and write ruby
variables, is it really necessary to have a web framework? Is there some
kind of simple service that allows that? All I want is... Well, store
data somewhere.
Well, think about how the web works.
1. A client clicks on a link, or clicks a submit button on a form
2. The client makes a HTTP GET or POST request to a web server
3. The web server generates some HTML and returns it to the client
What you need is a way for the generated HTML to depend on the contents
of your database. Web frameworks give you an easy way to do this. For
example with Sinatra you can write
get '/' do # <-- match incoming URL
"hello world" # <-- returned data
end
Sinatra runs under Rack, a generic API for connecting ruby web servers
to ruby applications. This means there are lots of ways to run your
application without modifying the code - as a standalone server
listening on a port, under Apache using Phusion Passenger, as a fastcgi
etc.
I'd recommend this approach as both quick to get started and yet very
flexible as you grow.
If you don't want to do this for any reason, the main alternatives are:
1. CGI - the web server will start a ruby interpreter with your script
when the incoming request arrives, setting information about the request
in environment variables. Google "ruby cgi" for examples.
2. eruby/erb - you write a HTML page with ruby embedded directly in it,
PHP-style. It's possible to configure a web server to serve this
directly.
CGI is inefficient because a new ruby interpreter is started for each
incoming request. You can make it persistent using fastcgi or scgi.
eruby/erb needs your web server specially configuring and can have
problems with one page being able to pollute the environment used by
another page.
HTH,
Brian.