Popular channels

codigo Ruby on Rails (para el que ya sabe)

Generar:

$ rails generate model User name:string email:string
$ rails generate controller StaticPages home help


Eliminar:

$ rails destroy model User
$ bundle exec rake db:drop:all (elimina toda la base de datos, despues con migrate la re-genera)


Actualizar base de datos:

$ bundle exec rake db:migrate

Rollback:
$ bundle exec rake db:rollback
$ bundle exec rake db:migrate VERSION=0 (rollback a la version 0)


Tests:
$ bundle exec rake test

Contenido dinamico:

views/layout/aplication.html.erb:
Incluir paginas: <%= yield %> (acá se incluira la pagina "index" "contact us", etc.
Partials: <%= render 'layouts/header' %>(trae a ese espacio _header.html.erb de layouts)

Title:
<% provide(:title, "Home" %>
...
<%= yield(:title) %> | Ruby on Rails Tutorial Sample App

Ruby:

Array:

>> "foo bar baz".split # Split a string into a three-element array.
=> ["foo", "bar", "baz"]
>> "fooxbarxbazx".split('x')
=> ["foo", "bar", "baz"]

>> a = [42, 8, 17]
>> a.first
=> 42
>> a.second
=> 8
>> a.last
=> 17
>> x = a.length # Like strings, arrays respond to the 'length' method.
=> 3
>> x == 3
=> true
0
0
0
0No comments yet