Páginas

martes 13 de diciembre de 2011

PHP Vim

Función para la correcta visualización de acentos y caracteres especiales:

Vim se ha convertido en mi editor favorito, sin quitar mérito a otros editores como Emacs (el monstruo de los editores de Linux y el preferido por los programadores, altamente configurable, rápido y potente, IDE utilizando plugins, etc..), jedit, gedit, komodo, etc. Para editar archivos de texto cualquier editor vale, pero, ¿y si queremos un IDE para programar en ruby, php, html, etc con función de autocompletado, explorador de archivos y poder abrir una terminal desde vim ?.
Vi con algunos plugins será suficiente:
NERD_tree Navegador de archivos:
La página de descarga es: http://www.vim.org/scrits/script.php?script_id=1658

Descomprimir el archivo NERD_tree.zip dentro del directorio ~/.vim
Asegúrese de comprobar que el archivo NERD_tree.vim esta en ~/.vim/plugin y NERD_tree.txt
en ~/.vim/doc.

Gentoo utiliza /var/www/localhost/htdocs como directorio predeterminado. El archivo
de configuración de vim y agregar está linea:

# vi /etc/vim/vimrc.local
" Teclado rápido para abrir explorador de archivos NERTree
map ex :NERDTree /var/www/localhost/htdocs

Conque es un plugin para vi que permite abrir una terminal sin salir de vi.
La página de descarga es:
http://www.vim.org/scripts/script.php?script_id=2771

Después de descargar el plugin debe abrirse con vi, acto seguido teclear
:so %

En este momento puede abrir una terminal desde vi:
:ConqueTermSplit bash

Utilizar teclas rápidas desde vi pasa por agregar al archivo de configuración
/etc/vim/vimrc.local:

# vi /etc/vim/vimrc.local
" Crear alias para abrir terminal dentro de vi
" la primera linea abre un terminal
" la segunda abre un terminal vertical (V).
map ct :ConqueTermSplit bash
map cv :ConqueTermVSplit bash

" mapeo para editar el fichero a traves del
" interprete de php
autocmd FileType php noremap :w!:!/usr/bin/php %

" mapeo para pasear la sintaxis del fichero
" a traves del interprete de php en modo lint
autocmd FileType php noremap :!/usr/bin/php -l %

" Activar autocompletado php y html
" ctrl + x para autocomplete
" ctrl +o muestra opciones de autocomplete
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags

Luego al abrir un archivo .php, para activar el autocompletado:
Ctrl + z y Ctrl + o.

Es importante saber que para movernos por las diferentes por las diferentes ventanas
utilzaremos las teclas Ctrl + w seguido de la tecla de dirección hacia la ventana que
queremos movernos, (Der, Izq, Arriba o Abajo).

Por último el plugin Tag List. Un plugin para el navegador de código fuente de Vim
y proporciona una visión general de la estructura de archivos de código fuente para
los diferentes lenguajes de programación. El link de descarga:

http://www.vim.org/scripts/script.php?script_id=273

Descomprimir el archivo taglist_45.zip en el directorio ~/.vim
Compruebe el archivo principal y la documentación:

plugin/taglit.vim
doc/taglis.txt

$ cd ~/.vim/doc
$ ~/.vim/doc $ ls -l
total 168
-rw-r--r-- 1 carlos users 27142 Nov 30 07:55 conque_term.txt
-rw-r--r-- 1 carlos users 50021 Dec  1  2009 NERD_tree.txt
-rwxr-xr-x 1 carlos users 69366 May 24  2007 taglist.txt
-rw-r--r-- 1 carlos users 10673 Dec 13 14:18 tags

Iniciar vim y dentro de vim en modo comando (Esc):
:helptags .  <--- no olvidar el punto. Este comando procesa la ayuda del archivo tatglist.


Linux es genial!.

domingo 13 de noviembre de 2011

Instalar ruby on rails

Instalar ruby rails en plataforma de desarrollo gentoo.
http://www.rubyonrails.org.es/
http://www.guateonrails.com Javier Alvarez.

Si están aprendiendo Ruby on Rails este es un sitio de visita obligada y visualicen los videos del sitio, excelentemente sencillos. Guateonrails.

Ruby es un lenguaje de programación interpretado que funciona con cualquier sistema operativo, aunque con los sistemas tipo Unix es que mejor se integra.


Instalar ruby:

# emerge -av ruby

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] app-admin/eselect-ruby-20100603  2 kB
[ebuild  N     ] dev-lang/ruby-1.8.7_p352  USE="berkdb gdbm ipv6 ncurses readline ssl -debug -doc -examples -libedit -rubytests -socks5 -threads -tk -xemacs" 4,112 kB

Total: 2 packages (2 new), Size of downloads: 4,114 kB

Would you like to merge these packages? [Yes/No] y

Instalar rubygems:

# emerge -av rubygems

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] dev-ruby/rubygems-1.3.7-r1  USE="-doc -server" RUBY_TARGETS="ruby18 -jruby -ree18" 285 kB

Total: 1 package (1 new), Size of downloads: 285 kB

Would you like to merge these packages? [Yes/No] y

Al finalzar la instalación un mensaje nos advierte:

 * To switch between available Ruby profiles, execute as root:
 * eselect ruby set ruby(18|19|...)

Procedemos:

# eselect ruby list
Available Ruby profiles:
  [1]   ruby18 (with Rubygems) *
# eselect ruby set ruby18
Successfully switched to profile:
  ruby18

Averiguar versión instalada:                
# gem -v
1.3.7

Instalar rails a través de Rubygem:

 # gem18 install rails --include-dependencies
INFO:  `gem install -y` is now default and will be removed
INFO:  use --ignore-dependencies to install only the gems you list
Building native extensions.  This could take a while...
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
...

En un futuro para actualizar Rails solo tendremos que teclear:

# gem update rails --include-dependencies

# emerge -av sqlite3-ruby

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] virtual/rubygems-1  RUBY_TARGETS="(ruby18)" 0 kB
[ebuild  N     ] dev-ruby/rake-0.8.7-r5  USE="-bash-completion -doc -test" RUBY_TARGETS="ruby18 -jruby -ree18" 101 kB
[ebuild  N     ] dev-ruby/hoe-2.8.0  USE="-doc -test" RUBY_TARGETS="ruby18 -jruby -ree18" 114 kB
[ebuild  N     ] dev-ruby/rake-compiler-0.7.5  USE="-test" RUBY_TARGETS="ruby18 -jruby -ree18" 26 kB
[ebuild  N     ] dev-ruby/sqlite3-ruby-1.3.2  USE="-doc -test" RUBY_TARGETS="ruby18 -ree18" 55 kB

Total: 5 packages (5 new), Size of downloads: 295 kB

Would you like to merge these packages? [Yes/No]

Instalar el paquete mysql de gems:

# gem install mysql
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
Installing RDoc documentation for mysql-2.8.1...

Verificar instalación y versión de rails:

# rails --version
Rails 3.1.1

Creando un esqueleto:
 $ rails new ~/code/ruby/weblog rails server
      create
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Enter your password to install the bundled RubyGems to your system:
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2)
Using multi_json (1.0.3)
Using activesupport (3.1.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.1)
Using erubis (2.7.0)
Using rack (1.3.5)
Using rack-cache (1.1)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.3)
Using actionpack (3.1.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.1)
Using arel (2.2.1)
Using tzinfo (0.3.31)
Using activerecord (3.1.1)
Using activeresource (3.1.1)
Using bundler (1.0.21)
Installing coffee-script-source (1.1.3)
Installing execjs (1.2.9)
Installing coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.1)
Using rdoc (3.11)
Using thor (0.14.6)
Using railties (3.1.1)
Installing coffee-rails (3.1.1)
Installing jquery-rails (1.0.17)
Using rails (3.1.1)
Installing sass (3.1.10)
Installing sass-rails (3.1.4)
Installing sqlite3 (1.3.4) with native extensions
Installing uglifier (1.0.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Comprobar dependencias:

$ bundle - Ruby
Using rake (0.9.2.2)
Using multi_json (1.0.3)
Using activesupport (3.1.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.1)
Using erubis (2.7.0)
Using rack (1.3.5)
Using rack-cache (1.1)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.3)
Using actionpack (3.1.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.1)
Using arel (2.2.1)
Using tzinfo (0.3.31)
Using activerecord (3.1.1)
Using activeresource (3.1.1)
Using bundler (1.0.21)
Using coffee-script-source (1.1.3)
Using execjs (1.2.9)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.1)
Using rdoc (3.11)
Using thor (0.14.6)
Using railties (3.1.1)
Using coffee-rails (3.1.1)
Using jquery-rails (1.0.17)
Using rails (3.1.1)
Using sass (3.1.10)
Using sass-rails (3.1.4)
Using sqlite3 (1.3.4)
Using uglifier (1.0.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

$ bundle show

Gems included by the bundle:
  * actionmailer (3.1.1)
  * actionpack (3.1.1)
  * activemodel (3.1.1)
  * activerecord (3.1.1)
  * activeresource (3.1.1)
  * activesupport (3.1.1)
  * arel (2.2.1)
  * builder (3.0.0)
  * bundler (1.0.21)
  * coffee-rails (3.1.1)
  * coffee-script (2.2.0)
  * coffee-script-source (1.1.3)
  * erubis (2.7.0)
  * execjs (1.2.9)
  * hike (1.2.1)
  * i18n (0.6.0)
  * jquery-rails (1.0.17)
  * json (1.6.1)
  * mail (2.3.0)
  * mime-types (1.17.2)
  * multi_json (1.0.3)
  * polyglot (0.3.3)
  * rack (1.3.5)
  * rack-cache (1.1)
  * rack-mount (0.8.3)
  * rack-ssl (1.3.2)
  * rack-test (0.6.1)
  * rails (3.1.1)
  * railties (3.1.1)
  * rake (0.9.2.2)
  * rdoc (3.11)
  * sass (3.1.10)
  * sass-rails (3.1.4)
  * sprockets (2.0.3)
  * sqlite3 (1.3.4)
  * thor (0.14.6)
  * tilt (1.3.3)
  * treetop (1.4.10)
  * tzinfo (0.3.31)
  * uglifier (1.0.4)

$ bundle check
The Gemfile's dependencies are satisfied


$ bundle update
Fetching source index for http://rubygems.org/
Enter your password to install the bundled RubyGems to your system:
Using rake (0.9.2.2)
Using multi_json (1.0.3)
Using activesupport (3.1.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.1)
Using erubis (2.7.0)
Using rack (1.3.5)
Using rack-cache (1.1)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.3)
Using actionpack (3.1.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.1)
Using arel (2.2.1)
Using tzinfo (0.3.31)
Using activerecord (3.1.1)
Using activeresource (3.1.1)
Using bundler (1.0.21)
Using coffee-script-source (1.1.3)
Using execjs (1.2.9)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.1)
Using rdoc (3.11)
Using thor (0.14.6)
Using railties (3.1.1)
Using coffee-rails (3.1.1)
Installing jquery-rails (1.0.18)
Using rails (3.1.1)
Using sass (3.1.10)
Installing sass-rails (3.1.5)
Using sqlite3 (1.3.4)
Installing uglifier (1.1.0)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem

Corregir error formato fecha:

# cd /usr/lib64/ruby/gems/1.8/specifications
# vim jquery-rails-1.0.17.gemspec

 cambiar:

 s.date = %q{2001-11-09 00.00.00 000000000Z}
por:
 s.date = %q{2011-11-13}

$ rails new ~/code/ruby/weblog
$ cd code/ruby/weblog/
$ bundle show

Corigiendo errores:

$ rails server
/usr/lib64/ruby/gems/1.8/gems/execjs-1.2.9/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

$ sudo gem install 'execjs'
Password:

Successfully installed execjs-1.2.9
1 gem installed
Installing ri documentation for execjs-1.2.9...
Installing RDoc documentation for execjs-1.2.9...

$ sudo gem install 'therubyracer'
Fetching: libv8-3.3.10.2-x86_64-linux.gem (100%)
Fetching: therubyracer-0.9.9.gem (100%)
Building native extensions.  This could take a while...
Successfully installed libv8-3.3.10.2-x86_64-linux
Successfully installed therubyracer-0.9.9
2 gems installed
Installing ri documentation for libv8-3.3.10.2-x86_64-linux...
Installing ri documentation for therubyracer-0.9.9...
Installing RDoc documentation for libv8-3.3.10.2-x86_64-linux...
Installing RDoc documentation for therubyracer-0.9.9...

$ sudo gem install 'libv8'
Fetching: libv8-3.3.10.2-x86-linux.gem (100%)
Successfully installed libv8-3.3.10.2-x86-linux
1 gem installed
Installing ri documentation for libv8-3.3.10.2-x86-linux...
Installing RDoc documentation for libv8-3.3.10.2-x86-linux...


Añadir las siguientes líneas al archivo ~/code/ruby/weblog/config/boot.rb:

$ cd ~/code/ruby/weblog/config
$ vim boot.rb

 require 'rubygems'
 require 'execjs'
 require 'v8'

Iniciar el servidor:

$ cd ~/code/ruby/weblog
$ rails server
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-11-13 16:50:49] INFO  WEBrick 1.3.1
[2011-11-13 16:50:49] INFO  ruby 1.8.7 (2011-06-30) [x86_64-linux]
[2011-11-13 16:50:49] INFO  WEBrick::HTTPServer#start: pid=10759 port=3000


Abrir firefox y teclear:
http://localhost:3000

Instalar jruby:
echo ">=dev-util/jay-1.1.1-r2 java" >> /etc/portage/package.use

# emerge -av jruby
These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] dev-java/javatoolkit-0.3.0-r6  17 kB
[ebuild  N     ] dev-java/ant-core-1.8.1  USE="-doc -source" 5,740 kB
[ebuild  N     ] dev-java/ant-nodeps-1.8.1  0 kB
[ebuild  N     ] dev-java/jcodings-1.0.4  USE="-source" 89 kB
[ebuild  N     ] dev-java/xml-commons-external-1.3.04  USE="-doc -source" 645 kB
[ebuild  N     ] dev-java/joda-time-1.6  USE="-doc -examples -source -test" 1,242 kB
[ebuild  N     ] dev-java/constantine-0.7  USE="-source -test" 65 kB
[ebuild  N     ] dev-java/bcel-5.2-r2  USE="-doc -findbugs -source" 256 kB
[ebuild   R    ] dev-util/jay-1.1.1-r2  USE="java* -mono" 0 kB
[ebuild  N     ] dev-java/jline-1.0  USE="-source -test" 453 kB
[ebuild  N     ] dev-java/javacup-0.11a_beta20060608  USE="-doc -source" 280 kB
[ebuild  N     ] dev-java/xjavac-20110814  3 kB
[ebuild  N     ] dev-java/xml-commons-resolver-1.2  USE="-doc -source" 257 kB
[ebuild  N     ] dev-java/touchgraph-graphlayout-1.22  USE="-source" 199 kB
[ebuild  N     ] dev-java/jgraph-5.12.0.4  USE="-doc -examples -source" 3,380 kB
[ebuild  N     ] dev-java/junit-3.8.2-r1  USE="-doc -source" 451 kB
[ebuild  N     ] dev-java/java-getopt-1.0.13  USE="-doc -source" 45 kB
[ebuild  N     ] dev-java/log4j-1.2.16  USE="-doc -javamail -jms -jmx -source" 2,727 kB
[ebuild  N     ] dev-java/jakarta-oro-2.0.8-r2  USE="-doc -examples -source" 338 kB
[ebuild  N     ] dev-java/commons-logging-1.1.1  USE="-avalon-framework -avalon-logkit -doc -log4j -servletapi -source -test" 187 kB
[ebuild  N     ] dev-java/bytelist-1.0.6  USE="-source -test" 15 kB
[ebuild  N     ] dev-java/jffi-1.0.0  USE="-source -test" 1,590 kB
[ebuild  N     ] dev-java/xalan-serializer-2.7.1  USE="-doc -source" 6,138 kB
[ebuild  N     ] dev-java/nailgun-0.7.1  USE="-doc -source -test" 1,455 kB
[ebuild  N     ] dev-java/jgrapht-0.7.3  USE="-doc -source -test" 1,113 kB
[ebuild  N     ] dev-java/jnr-x86asm-0.1  USE="-doc -source" 82 kB
[ebuild  N     ] dev-java/jvyamlb-0.2.5  USE="-source -test" 1,727 kB
[ebuild  N     ] dev-java/xerces-2.9.1  USE="-doc -examples -source" 1,672 kB
[ebuild  N     ] dev-java/xalan-2.7.1  USE="-doc -source" 0 kB
[ebuild  N     ] dev-java/bsf-2.4.0-r1  USE="-doc -examples -javascript -python -source -tcl" 293 kB
[ebuild  N     ] dev-java/ant-owanttask-1.1-r12  10 kB
[ebuild  N     ] dev-java/asm-3.2  USE="-doc -source" 832 kB
[ebuild  N     ] dev-java/jaffl-0.5.1  USE="-doc -source -test" 546 kB
[ebuild  N     ] dev-java/joni-1.1.4  USE="-source" 118 kB
[ebuild  N     ] dev-java/jnr-posix-1.1.4  USE="-source -test" 191 kB
[ebuild  N     ] dev-java/jnr-netdb-1.0.1  USE="-doc -source -test" 656 kB
[ebuild  N     ] dev-java/jruby-1.5.6  USE="ssl -bsf -doc -source -test" 10,905 kB
[ebuild   R    ] dev-ruby/rubygems-1.3.7-r1  USE="-doc -server" RUBY_TARGETS="jruby* -ree18 -ruby18*" 0 kB
[ebuild  NS    ] virtual/rubygems-2 [1] RUBY_TARGETS="(jruby)" 0 kB
[ebuild  N     ] dev-ruby/bouncy-castle-java-1.5.0146.1  USE="-test" RUBY_TARGETS="jruby" 1,945 kB
[ebuild  N     ] dev-ruby/jruby-openssl-0.7.4  USE="-doc -test" RUBY_TARGETS="(jruby)" 609 kB

Total: 41 packages (38 new, 1 in new slot, 2 reinstalls), Size of downloads: 46,250 kB

Would you like to merge these packages? [Yes/No] y

MySQL para Ruby:

# emerge -av dev-ruby/dbd-mysql

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] dev-ruby/mysql-ruby-2.8.2  USE="-test" RUBY_TARGETS="ruby18 -ree18" 32 kB
[ebuild  N     ] dev-ruby/deprecated-2.0.1-r1  USE="-test" RUBY_TARGETS="ruby18 -jruby (-ruby19)" 13 kB
[ebuild  N     ] dev-ruby/ruby-postgres-0.7.9.20080128-r2  USE="-test" RUBY_TARGETS="ruby18 -ree18" 32 kB
[ebuild  N     ] dev-ruby/ruby-dbi-0.4.3  USE="mysql postgres sqlite -examples -odbc -sqlite3 -test" RUBY_TARGETS="ruby18" 80 kB
[ebuild  N     ] dev-ruby/dbd-mysql-0.4.4  USE="-test" RUBY_TARGETS="ruby18" 56 kB
[ebuild  N     ] dev-ruby/dbd-pg-0.3.8  USE="-test" 64 kB
[ebuild  N     ] dev-ruby/dbd-sqlite-0.1.2  USE="-test" 52 kB

Total: 7 packages (7 new), Size of downloads: 327 kB

Would you like to merge these packages? [Yes/No] y

>>> Verifying ebuild manifests

>>> Starting parallel fetch
....

$ sudo gem install mysql
Password: 
Building native extensions.  This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
Installing ri documentation for mysql-2.8.1...
Installing RDoc documentation for mysql-2.8.1..

Iniciar un nuevo proyecto Ruby on Rails utilizando MysQL:
$ rails new webservmysql -d mysql
 create  
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
...

$ cd webservmysl

En otra terminal:
MySQL debe estar iniciado:
# /etc/initd/mysql start

$ mysql -u root -p
Enter password:




mysql> CREATE DATABASE webservmysql;
Query OK, 1 row affected (0.00 sec)

mysql> use webservmysql;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> show tables;

+------------------------+
| Tables_in_webservmysql |
+------------------------+
| schema_migrations      |
+------------------------+
1 row in set (0.00 sec)


El archivo database.yml se verá así:
carlos@hypatia ~/code/webservmysql/config $ vi database.yml


Crear un modelo y migrar la base de datos (creará la tabla Persona):

carlos@hypatia ~/code/webservmysql $ rails g model Persona nombre:string      invoke  active_record
      create    db/migrate/20111127091342_create_personas.rb
      create    app/models/persona.rb
      invoke    test_unit
      create      test/unit/persona_test.rb
      create      test/fixtures/personas.yml
carlos@hypatia ~/code/webservmysql $ rake db:migrate
==  CreatePersonas: migrating =================================================
-- create_table(:personas)
   -> 1.6301s
==  CreatePersonas: migrated (1.6303s) ========================================

Ahora si volvemos la terminal anterior y nuevamente hacemos un show tables veremos la tabla persona ya creada:

mysql> show tables;
+------------------------+
| Tables_in_webservmysql |
+------------------------+
| personas               |
| schema_migrations      |
+------------------------+
2 rows in set (0.00 sec)





Linux es genial!.