Date post: | 27-Jun-2015 |
Category: |
Technology |
Upload: | aitor-rey |
View: | 993 times |
Download: | 0 times |
Ruby on Rails:Comedia en 3 actos
I.PrólogoO de cómo un lenguaje creado en Japón y un framework hecho por un tío danés pueden tener algo que ver con tu vida.
Linux“..
.Inst
alan
do q
ue e
s ger
undi
o...”
Windows
http://bitnami.org/stack/rubystack
“...In
stal
ando
que
es g
erun
dio.
..”
Buenas intros“..
.y se
hiz
o Ru
by...
”
http://www.humblelittlerubybook.com/
http://www.ruby-lang.org/es/documentation/
Podéis tener abierto...“..
.y se
hiz
o Ru
by...
”
http://www.ruby-lang.org/es/documentation/quickstart/
http://railsapi.com/
“...y
se h
izo
Ruby
...”
Snippetsen Textmate e IRB
II. Romance O de cómo te puedes enamorar de una tecnología en 30 minutos.
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
1 # SQLite version 3.x 2 # gem install sqlite3-ruby (not necessary on OS X Leopard) 3 development: 4 adapter: sqlite3 5 database: db/development.sqlite3 6 pool: 5 7 timeout: 5000 8 9 # Warning: The database defined as "test" will be erased and 10 # re-generated from your development database when you run "rake". 11 # Do not set this db to the same as development or production. 12 test: 13 adapter: sqlite3 14 database: db/test.sqlite3 15 pool: 5 16 timeout: 5000 17 18 production: 19 adapter: sqlite3 20 database: db/production.sqlite3 21 pool: 5 22 timeout: 5000
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
Hello, Rails!
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
Scaffolding
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
” Scaffolding
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”Migration
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”Migration
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
Bingo!(revisemos...)
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
DRY
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
” 1 class CommentsController < ApplicationController 2 def index 3 @post = Post.find(params[:post_id]) 4 @comments = @post.comments 5 end 6 7 def show 8 @post = Post.find(params[:post_id]) 9 @comment = @post.comments.find(params[:id]) 10 end 11 12 def new 13 @post = Post.find(params[:post_id]) 14 @comment = @post.comments.build 15 end 16 17 def create 18 @post = Post.find(params[:post_id]) 19 @comment = @post.comments.build(params[:comment]) 20 if @comment.save 21 redirect_to post_comment_url(@post, @comment) 22 else 23 render :action => "new" 24 end 25 end 26
“... e
n el
pri
ncip
io re
inab
an la
s tin
iebl
as...
”27 def edit 28 @post = Post.find(params[:post_id]) 29 @comment = @post.comments.find(params[:id]) 30 end 31 32 def update 33 @post = Post.find(params[:post_id]) 34 @comment = Comment.find(params[:id]) 35 if @comment.update_attributes(params[:comment]) 36 redirect_to post_comment_url(@post, @comment) 37 else 38 render :action => "edit" 39 end 40 end 41 42 def destroy 43 @post = Post.find(params[:post_id]) 44 @comment = Comment.find(params[:id]) 45 @comment.destroy 46 47 respond_to do |format| 48 format.html { redirect_to post_comments_path(@post) } 49 format.xml { head :ok } 50 end 51 end 52 53 end
Intermedio
III.Tocata y fugaO de cómo lo que parecía una sola cosa es en realidad diferentes partes que funcionan juntas y tienen su propia alma.
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
ActiveRecordActionControllerActionViewMigrations
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
validates_presence_ofvalidates_uniqueness_ofvalidates_associated
etc...
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
Relaciones
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
La manera coñazo:
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
Rails way:
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
Tipos
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
belongs_to
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
has_one
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
has_many
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
has_many :through
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
has_many :through“..
. sob
re tí
leva
ntar
é m
i igl
esia
...”
has_many :through como atajo
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
Polimórficas
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
Polimórficas
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
Metodos añadidos por las relaciones“..
. sob
re tí
leva
ntar
é m
i igl
esia
...”
Metodos añadidos por las relaciones
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
Callbacks
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
Callbacks
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
Extensiones
“... s
obre
tí le
vant
aré
mi i
gles
ia...
”
Querys
Escenario
Migraciones
Fin y Comienzo