<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3452395458289460741</id><updated>2012-02-17T02:07:19.313-02:00</updated><category term='NeoBux'/><category term='Modelo'/><category term='yield'/><category term='Arreglos'/><category term='Busquedas'/><category term='Ruby'/><category term='Rails'/><category term='Selenium'/><category term='Filters'/><category term='Rails y Scriptaculus'/><category term='Otros'/><category term='Money'/><category term='Lo basico'/><category term='Routes'/><category term='Ajax'/><category term='Migrations'/><category term='Validaciones'/><category term='Dinero'/><category term='Testing'/><title type='text'>Pic on Rails</title><subtitle type='html'>Sitio donde encontraras todo lo que deseas saber de ruby on rails en español y con ejemplos</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>27</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-8157641373267914500</id><published>2009-10-30T09:25:00.004-02:00</published><updated>2009-10-30T09:30:48.769-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Money'/><category scheme='http://www.blogger.com/atom/ns#' term='Dinero'/><category scheme='http://www.blogger.com/atom/ns#' term='NeoBux'/><title type='text'>Probando NeoBux</title><content type='html'>Estoy probando el sistema NeoBux cualquiera que tenga ganas de ver si funciona (supuestamente te pagan por cada clic que realices), bueno les dejo el link por si les interesa&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.neobux.com/?r=elneopic"&gt;&lt;img src="http://images.neobux.com/imagens/banner3.gif" width="125" border="0" height="125" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-8157641373267914500?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/8157641373267914500/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=8157641373267914500&amp;isPopup=true' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/8157641373267914500'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/8157641373267914500'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2009/10/probando-neobux.html' title='Probando NeoBux'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-5027178577625607531</id><published>2009-07-23T09:58:00.002-03:00</published><updated>2009-07-23T10:19:47.705-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='Selenium'/><category scheme='http://www.blogger.com/atom/ns#' term='Rails'/><title type='text'>Selenium ejemplo</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;Como instalar selenium en rails&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;b&gt;ruby script/plugin install http://svn.openqa.org/svn/selenium-on-rails/selenium-on-rails&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Una vez que esta instalado en nuestro proyecto debemos configurarlo, para eso debemos hacer lo siguiente copiamos el archivo que se encuentra en vendor/plugins/selenium-on-rails/ llamado config.yml.example a config/ y lo renombramos como selenium.yml. Luego lo editamos y para configurarlo seguimos los pasos que dice dentro del archivo.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Una vez que se termino de configurar, vamos a hacer un archivo de prueba, para ellos corremos el siguiente comando en la carpeta del proyecto &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;ruby script/generate selenium login.rsel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;, esto nos genera una carpeta test/selenium en caso de que no exista y el archivo login.rsel, bien ahora que se puede hacer con el archivo&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;archivo login.rsel&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;setup&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;open "&lt;span class="Apple-style-span"  style="color:#000099;"&gt;/&lt;/span&gt;" &lt;span class="Apple-style-span"  style="color:#666666;"&gt;# =&gt; Abre el navegador en la url que se configuro en selenium.yml&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;assert_title "&lt;span class="Apple-style-span"  style="color:#000099;"&gt;Titulo de la pagina&lt;/span&gt;" &lt;span class="Apple-style-span"  style="color:#666666;"&gt;# =&gt; Hace el assert con respecto al titulo de la pagina&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;type "&lt;span class="Apple-style-span"  style="color:#000099;"&gt;user_email&lt;/span&gt;", "&lt;span class="Apple-style-span"  style="color:#000099;"&gt;usuario&lt;/span&gt;" &lt;span class="Apple-style-span"  style="color:#666666;"&gt;#&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#666666;"&gt; =&gt; Escribe en el input user_email el texto usuario&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;type "&lt;span class="Apple-style-span"  style="color:#000099;"&gt;user_password&lt;/span&gt;", "&lt;span class="Apple-style-span"  style="color:#000099;"&gt;pass&lt;/span&gt;" &lt;span class="Apple-style-span"  style="color:#666666;"&gt;# =&gt; Escribe en el input user_password el texto pass&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;click "&lt;span class="Apple-style-span"  style="color:#000099;"&gt;commit&lt;/span&gt;" &lt;span class="Apple-style-span"  style="color:#666666;"&gt;# =&gt; Hace click en el commit&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;wait_for_page_to_load 20000 &lt;span class="Apple-style-span"  style="color:#666666;"&gt;# =&gt; Espera a que se termine de cargar la pagina tiene un timeout de 20000ms&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;b&gt;assert_title "&lt;span class="Apple-style-span"  style="color:#000099;"&gt;Nuevo titulo de la pagina&lt;/span&gt;" &lt;span class="Apple-style-span"  style="color:#666666;"&gt;# =&gt; Hace el assert con respecto al titulo de la pagina&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-5027178577625607531?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/5027178577625607531/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=5027178577625607531&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/5027178577625607531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/5027178577625607531'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2009/07/selenium-ejemplo.html' title='Selenium ejemplo'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-1515219332754099432</id><published>2009-07-22T10:57:00.002-03:00</published><updated>2009-07-22T11:09:05.778-03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Rails y Scriptaculus'/><title type='text'>Serializacion de elementos</title><content type='html'>&lt;span style="font-family: lucida grande;"&gt;Dentro de una pagina web nosotros podemos serializar algunos elementos (para hacer peticiones ajax o cualquier otra cosa que se nos ocurra). &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: lucida grande;"&gt;Scriptaculus nos ofrece una manera sencilla de hacerlo, por ejemplo si queremos serializar un form &lt;/span&gt;&lt;span style="color: rgb(0, 153, 0); font-family: lucida grande;font-size:85%;" &gt;&lt;span style="font-family: courier new;"&gt;Form.serialize('id_del_form')&lt;/span&gt;, &lt;/span&gt;&lt;span style="font-family: lucida grande;"&gt;tambien podemos serializar cualquier otro objeto que lo permita utilizando también &lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt;&lt;span style="font-family: courier new;"&gt;Form.serialize('id_del_objeto')&lt;/span&gt;&lt;/span&gt; o directamente obteniendo el objeto por id y serializandolo &lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt;&lt;span style="font-family: courier new;"&gt;$('id_del_objeto').serialize()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: lucida grande;"&gt;En rails esto nos sirve por ejemplo para utilizar el siguiente helper&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);font-size:85%;" &gt;&lt;span style="font-family: courier new;"&gt;observe_field("id_campo", :url =&gt; action_path, :update =&gt; "en caso de que quieras actualizar algo", :with =&gt; "$('objeto').serialize()")&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-1515219332754099432?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/1515219332754099432/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=1515219332754099432&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/1515219332754099432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/1515219332754099432'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2009/07/serializacion-de-elementos.html' title='Serializacion de elementos'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-3875538410486071071</id><published>2009-03-26T12:02:00.002-03:00</published><updated>2009-03-26T12:06:42.679-03:00</updated><title type='text'>Scroll con javascript y prototype</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: verdana;"&gt;He escrito un script para hacer scroll con javascript, es muy sencillo de utilizar para ver ejemplos ir a la pagina &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://www.assembla.com/wiki/show/dJVe6ogHur3Q7ceJe5aVNr"&gt;http://www.assembla.com/wiki/show/dJVe6ogHur3Q7ceJe5aVNr&lt;/a&gt;&lt;span style="font-family: verdana;"&gt;, y para bajarlo o ver el codigo fuente ir a &lt;/span&gt;&lt;a style="font-family: verdana;" href="http://code.assembla.com/scroller/subversion/nodes"&gt;http://code.assembla.com/scroller/subversion/nodes&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-3875538410486071071?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/3875538410486071071/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=3875538410486071071&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/3875538410486071071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/3875538410486071071'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2009/03/scroll-con-javascript-y-prototype.html' title='Scroll con javascript y prototype'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-1460884264841253407</id><published>2009-02-09T15:05:00.002-02:00</published><updated>2009-02-15T11:38:42.593-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Arreglos'/><title type='text'>Ordenar array utilizando multiples elementos</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: verdana;"&gt;Supongamos que tenemos un arreglo que tiene un objeto que tiene dos atributos llamados red_cards y yellow_cards (estos dos atributos son numericos),  ahora lo que queremos hacer es ordenar el array primero por la cantidad de tarjetas rojas y luego por la cantidad de amarillas.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;Lo podemos hacer de la siguiente manera:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(0, 0, 153);"&gt;array.sort! {|x, y| ((y.red_cards * 1000) + y.yellow_cards) &lt;=&gt; ((x.red_cards * 1000) + x.yellow_cards) }&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family: verdana;"&gt;Elegimos 1000 por que sabemos que nunca se va a tener ese numero de tarjetas.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-1460884264841253407?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/1460884264841253407/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=1460884264841253407&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/1460884264841253407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/1460884264841253407'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2009/02/ordenar-array-utilizando-multiples.html' title='Ordenar array utilizando multiples elementos'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-3759208816482299817</id><published>2009-01-30T11:22:00.004-02:00</published><updated>2009-02-09T15:05:29.187-02:00</updated><title type='text'>Codigo para generar un fixture de futbol (muy eficiente)</title><content type='html'>&lt;span style="color: rgb(0, 0, 0);font-size:85%;" &gt;&lt;span style="font-family:verdana;"&gt;Aca les dejo un codigo que sirve para generar un fixture de futbol, de la manera mas eficiente que he visto hasta el momento.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Para genrar un fixture lo que debes hacer es DeportFixture.new(lista de cuadros).groups eso te debuelve el fixture.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-size:85%;" &gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;class DeportFixture&lt;br /&gt;&lt;br /&gt;  def initialize(elements)&lt;br /&gt;    @elements = elements&lt;br /&gt;    @elements &lt;&lt; nil if elements.length.odd?&lt;br /&gt;    @round_number = @elements.length - 1&lt;br /&gt;    @rounds = Array.new(@round_number, nil)&lt;br /&gt;    @last_element = @elements[-1]&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def groups&lt;br /&gt;    fixture = Array.new(@round_number, nil)&lt;br /&gt;   &lt;br /&gt;    @round_number.times do |time|&lt;br /&gt;      @rounds[time] ||= []&lt;br /&gt;&lt;br /&gt;      if time == 0&lt;br /&gt;        (@elements.length / 2).times do |element_id|&lt;br /&gt;          @rounds[time] &lt;&lt; @elements[element_id]&lt;br /&gt;          @rounds[time] &lt;&lt; @elements[-(element_id+1)]&lt;br /&gt;        end&lt;br /&gt;      else&lt;br /&gt;        previous_round = @rounds[time-1].clone&lt;br /&gt;        first_element, second_element = previous_round[-1], @last_element&lt;br /&gt;        first_element, second_element = @last_element, previous_round[-1] if time.odd?&lt;br /&gt;&lt;br /&gt;        previous_round.delete(first_element)&lt;br /&gt;        previous_round.delete(second_element)&lt;br /&gt;        previous_round.compact!&lt;br /&gt;&lt;br /&gt;        @rounds[time] &lt;&lt; first_element&lt;br /&gt;        @rounds[time] &lt;&lt; second_element&lt;br /&gt;&lt;br /&gt;        new_round_elements = []&lt;br /&gt;&lt;br /&gt;        while not previous_round.empty?&lt;br /&gt;          elements = previous_round.slice!(-2,2)&lt;br /&gt;&lt;br /&gt;          elements.each {|element| new_round_elements &lt;&lt; element}&lt;br /&gt;        end&lt;br /&gt;&lt;br /&gt;        new_round_elements.each {|element| @rounds[time] &lt;&lt; element}&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    @rounds.each_with_index do |round, index|&lt;br /&gt;      fixture[index] = []&lt;br /&gt;&lt;br /&gt;      (round.length / 2).times do |team|&lt;br /&gt;        item_1 = round[(team * 2)]&lt;br /&gt;        item_2 = round[(team * 2) + 1]&lt;br /&gt;        fixture[index] &lt;&lt; [item_1, item_2] unless item_1.nil? or item_2.nil?&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    fixture&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-3759208816482299817?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/3759208816482299817/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=3759208816482299817&amp;isPopup=true' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/3759208816482299817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/3759208816482299817'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2009/01/codigo-para-generar-un-fixture-de.html' title='Codigo para generar un fixture de futbol (muy eficiente)'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-166945041603406096</id><published>2008-12-16T12:30:00.006-02:00</published><updated>2008-12-16T12:51:21.132-02:00</updated><title type='text'>Nuevo plugin</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;He creado un nuevo plugin que nos ayudara a escribir codigo javascript mas claro en las vistas es bastante sencillo en realidad pero queria subirlo para los que escriben algo de codigo javascript en las vistas, la idea es utilzar el mismo helper que se utiliza en los rjs, bueno les dejo la direccion &lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Wiki:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="line-height: 18px; "&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; vertical-align: baseline; "&gt;&lt;a href="http://www.assembla.com/wiki/show/view_javascript_helper" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; vertical-align: baseline; padding-top: 1px; padding-right: 0px; padding-bottom: 1px; padding-left: 0px; text-decoration: underline; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;http://www.assembla.com/wiki/show/view_javascript_helper&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/pre&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; vertical-align: baseline; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; vertical-align: baseline; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Svn:&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; vertical-align: baseline; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; vertical-align: baseline; "&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; vertical-align: baseline; "&gt;&lt;a href="http://subversion.assembla.com/svn/view_javascript_helper" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; vertical-align: baseline; padding-top: 1px; padding-right: 0px; padding-bottom: 1px; padding-left: 0px; text-decoration: underline; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;http://subversion.assembla.com/svn/view_javascript_helper&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Agile Web Development:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://agilewebdevelopment.com/plugins/view_javascript_helper"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;http://agilewebdevelopment.com/plugins/view_javascript_helper&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-166945041603406096?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/166945041603406096/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=166945041603406096&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/166945041603406096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/166945041603406096'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/12/nuevo-plugin.html' title='Nuevo plugin'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-1544563030710650834</id><published>2008-12-15T10:38:00.003-02:00</published><updated>2008-12-15T10:43:56.147-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ajax'/><title type='text'>Ajax</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Cuando necesitamos hacer cosas con ajax, existe un helper que nos facilita ciertas cosas como por ejemplo si queremos actualizar el div de un elemento por ejemplo el div con id element_5 (siendo element el modelo) podemos utilizar el helper div_for o content_tag_for en el primero simplemente le pasamos el modelo y el nos genera automaticamente un div con el id y la clase asociados a nuestro modelo y el segundo ademas de ese parametro le tenemos que pasar el elemento que deseamos generar.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Ejemplo&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;@post = Post.find(3)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;div_for @post do&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;# Contenido del div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;luego cuando llamamos a la accion ajax acutalizamos el elemento con el id post_3 (para este ejemplo) , ya que la linea de arriba nos genera un div que tiene como id post_3 y como clase pos&lt;/span&gt;&lt;/span&gt;t&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-1544563030710650834?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/1544563030710650834/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=1544563030710650834&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/1544563030710650834'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/1544563030710650834'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/12/ajax.html' title='Ajax'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-8812714068942562017</id><published>2008-11-12T12:06:00.003-02:00</published><updated>2008-11-12T12:09:29.058-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Routes'/><title type='text'>Como saber todas las rutas de un proyecto</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Para conocer todas las rutas que estan definidas en el archivo de rutas y a que controller se dirige cada una basta con hacer lo siguiente:&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Lo primero que debemos hacer es ir a la ruta de la aplicción en una ventana de comandos, y en ella escribimos &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;rake routes &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Esto nos envia las rutas por pantalla, si las deseamos almacenar en un archivo&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;rake routes &gt; "archivo.txt"&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-8812714068942562017?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/8812714068942562017/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=8812714068942562017&amp;isPopup=true' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/8812714068942562017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/8812714068942562017'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/11/como-saber-todas-las-rutas-de-un.html' title='Como saber todas las rutas de un proyecto'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-5980773123403248721</id><published>2008-11-07T08:54:00.009-02:00</published><updated>2008-11-11T09:17:07.673-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><title type='text'>Funciones de Strings</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;En este post voy a poner algunas de las funciones interesantes de los string en ruby&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Dado un string&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;cadena = " Hola "&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Para retornar el largo de una cadena&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;cadena.length o cadena.length()&lt;/span&gt; &lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# retorna 6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Para retornar la cantidad de una letra x&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;cadena.count('o')&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# retorna 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Para sacarle los espacios en blanco de la izquierda y derecha&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;cadena.strip&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# retorna la cadena sin los espacios en blanco en la&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;       &lt;/span&gt;# izquierda y derecha&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102); font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px; "&gt;Para concatenarle elementos a un string&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;numero = 5&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;cadena_texto "hola"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;"esta es la cadena #{cadena_texto} y este es el numero #{numero}" &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;# retorna la cadena "esta es la cadena hola y este es el numero 5"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;Para repetir un string x veces&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;cadena * 5&lt;/span&gt; &lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# " Hola  Hola  Hola  Hola  Hola "&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102); font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px; "&gt;Como obtener una parte de un string&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;cadena[0..2]&lt;/span&gt; &lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# " Ho"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102); font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px; "&gt;Para dar vulta un string&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;cadena.reverse&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# " aloH "&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Para hacer que un string quede todo en mayuscula&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;cadena.upcase&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# " HOLA "&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;Para hacer que quede todo en minuscula&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;cadena.downcase&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt; &lt;/span&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# " hola "&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;Para dejarlo en la forma camel&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;"hola_como_andas".camelize&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# "HolaComoAndas"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Para volver la cadena a como se encontraba antes&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;"HolaComoAndas".underscore&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# "hola_como_andas"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Para dejar una cadena con la forma de titulo&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;"hola esto es un titlo"&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# "Hola Esto Es Un Titulo"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;"titlo-subtitulo"&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# "Titulo Subtitulo"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Para poner en plural una palabra (por defecto solo funciona en ingles, si queres que funcione en español hay que tocar el archivo inflections.rb)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;"user".pluralize&lt;/span&gt; &lt;span class="Apple-tab-span" style="white-space:pre"&gt;   &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;# "users"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;div&gt;Para poner en singular una palabra (por defecto solo funciona en ingles, si queres que funcione en español hay que tocar el archivo inflections.rb)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102);"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;"users".singularize&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;   &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(102, 102, 102); "&gt;# "user"&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-5980773123403248721?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/5980773123403248721/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=5980773123403248721&amp;isPopup=true' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/5980773123403248721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/5980773123403248721'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/11/funciones-de-strings.html' title='Funciones de Strings'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-6938597788341607530</id><published>2008-11-06T08:59:00.004-02:00</published><updated>2008-11-06T09:45:22.672-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Otros'/><title type='text'>Position absolute and relative</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Lo que voy a postear aqui es como hacer que un div tenga posicion absoluta con respecto a otro div, en lugar de tener posicion absoluta con respecto a el body&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Lo que debemos hacer si queremos que un div tenga posicion absoluta con respecto a otro es lo siguiente, el primer div que creamos o sea el contenedor debe tener posicion relativa y el contenido debe tener posicion absoluta de esa manera conseguimos que el contenido tenga posicion absoluta con respecto al contenedor&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-6938597788341607530?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/6938597788341607530/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=6938597788341607530&amp;isPopup=true' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/6938597788341607530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/6938597788341607530'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/11/position-absolute-and-relative.html' title='Position absolute and relative'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-4654869333495842333</id><published>2008-11-04T09:05:00.002-02:00</published><updated>2008-11-04T09:08:55.955-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Filters'/><title type='text'>Como evitar validacion de token</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Para las acciones ajax muchas veces no nos interesa que se haga la validación del token de autenticidad, por lo cual aqui les voy a mostrar como hacer para evitar la misma&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;skip_before_filter :verify_authenticity_token, :only =&gt; [:action]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;en :action se debe poner la accion que se desea que no valide el token de autenticidad&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-4654869333495842333?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/4654869333495842333/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=4654869333495842333&amp;isPopup=true' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/4654869333495842333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/4654869333495842333'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/11/como-evitar-validacion-de-token.html' title='Como evitar validacion de token'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-4945447744623389309</id><published>2008-10-31T10:43:00.005-02:00</published><updated>2008-11-02T12:21:37.293-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Busquedas'/><category scheme='http://www.blogger.com/atom/ns#' term='Modelo'/><title type='text'>Named Scope</title><content type='html'>&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Los named_scope nos sirven para definir consultas que vamos a utilizar muy a menudo, estos metodos se definen en el modelo y son estaticas o sea si definimos un named_scope llamado activos en el modelo User, lo vamos a acceder de la siguiente manera User.activos, lo que tiene de interesante los named_scope es que pueden recibir parametros, ahora vamos a ver algunos ejemplos para que sean mas faciles de entender&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;class User &lt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;  named_scope :active, :conditions =&gt; {:active =&gt; true}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;  named_scope :find_with_ids, lambda { |ids| {:conditions =&gt; ["id in (?)", ids] }} &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;El primer named_scope que definimos(active) nos permite buscar a todos los usuarios que este activos de la siguiente manera&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;User.active&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;El segundo named_scope es un poco mas complejo, lo que nos permite es buscar a todos los usuarios que tengan un id que este en la lista que le pasamos como parametro.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;user_ids = [1,2,34, 56]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;User.find_with_ids(user_ids)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Esto nos debuelve la lista de usuario cuyo id sea igual a alguno de los numeros que esta en el array.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-4945447744623389309?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/4945447744623389309/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=4945447744623389309&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/4945447744623389309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/4945447744623389309'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/named-scope.html' title='Named Scope'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-4456224175378821695</id><published>2008-10-30T09:18:00.005-02:00</published><updated>2008-10-31T10:43:06.116-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Validaciones'/><category scheme='http://www.blogger.com/atom/ns#' term='Modelo'/><title type='text'>Validar que un atributo sea numerico (validates_numericality_of)</title><content type='html'>&lt;span class="Apple-style-span"   style="  ;font-family:verdana;font-size:13px;"&gt;Cuando deseamos validar que un atributo de nuestro modelo sea numerico, lo que podemos hacer es agregarle la siguiente linea al modelo, esta validación incluye opciones que nos permiten hacer que el atributo este en un rango determinado entre otras cosas:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;validates_numericality_of :&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 18px; white-space: normal; "&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;atributo_a_validar&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;, :opciones&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px; font-family:verdana;font-size:13px;"&gt;Cuando el atributo al que se le desea validar si es numerico no cumple con lo que se le especifica en las opciones el mismo es agregado a una lista de errores que tiene el objeto del modelo.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px; font-family:verdana;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px; font-family:verdana;font-size:13px;"&gt;:atributo_a_validar - es el atributo al cual deseamos validarle el largo&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px; font-family:verdana;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px; font-family:verdana;font-size:13px;"&gt;:opciones - las opciones deben ir separadas por comas&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px; font-family:verdana;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px; font-family:verdana;font-size:13px;"&gt;:message =&gt; mensaje, nos permite cambiar el mensaje que está asociado por defecto a el error, el mensaje por defecto es el siguiente "is not a number".&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:on =&gt; nos define en que momento se va a hacer dicha validación por defecto es en el salvado del objeto, pero se puede especificar :create o :update.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:only_integer =&gt; nos especifica que el objeto a validar solo puede ser un entero por defecto esta en false.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:allow_nil =&gt; esquiva esta validación si el objeto es nil, esta opcion esta por defecto en false&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:greater_than =&gt; especifica que el valor del atributo debe ser mayor que el numero que le indiquemos.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:greater_than_or_equal_to =&gt; especifica que el valor del atributo debe ser mayor o igual que el numero que le indiquemos.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:equal_to =&gt; especifica que el valor del atributo debe ser igual que el valor que le indiquemos&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:less_than =&gt; especifica que el valor del atributo debe ser menor que el valor que le indiquemos&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:less_than_or_equal_to =&gt; especifica que el valor que le indiquemos debe ser menor o igual que el valor que le indiquemos&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:odd =&gt; indica que el atributo debe ser impar&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:even =&gt; nos indica que el atributo debe ser par&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:if =&gt; especifica un metodo, procedimiento o string que se utiliza para saber si realizar la validacion, este metodo debe retornar un valor booleano&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;:unless =&gt; especifica un metodo, procedimiento o string que se utiliza para saber si no se debe realizar la validacion, este metodo debe retornar un valor booleano&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;Ejemplos:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;Valida el atributo number del modelo cuando el mismo se actualiza&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;validates_numericality_of :number, :on =&gt; :update &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" line-height: 18px; font-size:13px;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Valida que el atributo number del modelo sea mayor que 10&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  line-height: 18px;font-family:verdana;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:'courier new';"&gt;validates_numericality_of :number, :greater_than =&gt; 10&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" line-height: 18px; font-size:13px;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Valida que el atributo number del modelo sea mayor o igual que 5 y menor que 10&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;validates_numericality_of :number, :greater_than_or_equal_to =&gt; 5, :less_than =&gt; 10&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" line-height: 18px; font-size:13px;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Valida que el atributo number del modelo sea igual a 2 si el atributo name es igual a "pepe"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;validates_numericality_of :number, :equal_to =&gt; 2, :if =&gt; :name_validation&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;def name_validation&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;  self.name == "pepe"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);   line-height: 18px;font-family:'courier new';font-size:13px;"&gt;end&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  white-space: pre;font-family:Arial;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style="color: rgb(51, 51, 51);  line-height: 18px; white-space: normal; font-family:'Trebuchet MS';"&gt;&lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-4456224175378821695?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/4456224175378821695/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=4456224175378821695&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/4456224175378821695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/4456224175378821695'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/validar-que-un-atributo-sea-numerico.html' title='Validar que un atributo sea numerico (validates_numericality_of)'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-8986078620034760700</id><published>2008-10-28T17:15:00.003-02:00</published><updated>2008-10-29T10:06:45.005-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Otros'/><title type='text'>Como evitar el doble submit</title><content type='html'>&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Un problema tipico de la programación web es el doble submit, esto ocurre cuando un usuario luego de ingresar la información en un form hace varios clicks en el input submit. &lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Una manera de evitar esto es mediante javascript, en nuestro caso que estamos utilizando rails lo podemos agregar en el application.js, pero se puede agregar en cualquier js que utilizemos en las paginas que estemos desarrollando.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Para agregar este ejemplo debemos agregar la libreria de prototype.js&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;var SubmitHelper = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;  disableFormsOfPage: function(){&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;$$('form').each(function(form) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;form.observe('submit', function() {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;form.getInputs('submit').each(function(submit) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;if (!submit.readAttribute("no_disabled")){&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;            &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;submit.value = "Trabajando...";&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;            &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;submit.disable();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  ;font-family:'courier new';font-size:13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;  init: function(){&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'courier new';font-size:13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;    Event.observe(window, 'load', SubmitHelper.disableFormsOfPage.&lt;/span&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'courier new';font-size:13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;bindAsEventListener()&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"   style="  ;font-family:'courier new';font-size:13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'courier new';font-size:13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'courier new';font-size:13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'courier new';font-size:13px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;SubmitHelper.init();&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 153);  font-family:'courier new';font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Bien ahora vamos a explicar un poco lo que hace el codigo lo que hacemos es recorrer todos los forms que hay en la pagina y para cada uno de ellos observamos el submit, una vez que ocurre dicho evento lo que hacemos es obtener el input que realizo el submit y a este le preguntamos si tiene el atributo &lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:'courier new';"&gt;no_disabled&lt;/span&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;(&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;este atributo es agregado por nosotros y lo que indica es que a este boton no hay que desabilitarlo) en caso de que no exista se le setea el valor "Trabajando...", el valor puede ser cualquiera o dejar el que ya tiene y luego lo deshabilitamos.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;Suponiendo que estamos adentro de un form&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&amp;lt;input type="submit" value="Crear"&amp;gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;En este caso si agregamos el javascript  que escribimos mas arriba el boton se deshabilita al momento de hacer submit y escribe el texto "Trabajando..."&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;span class="Apple-style-span"   style="  white-space: pre-wrap; font-family:-webkit-monospace;font-size:13px;"&gt;&amp;lt;input type="submit" value="Crear" no_disabled="true"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;En este caso el boton no se deshabilita&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-8986078620034760700?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/8986078620034760700/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=8986078620034760700&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/8986078620034760700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/8986078620034760700'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/como-evitar-el-doble-submit.html' title='Como evitar el doble submit'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-6882121719812069035</id><published>2008-10-28T09:50:00.002-02:00</published><updated>2008-10-28T09:58:49.020-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Arreglos'/><title type='text'>Borrar elementos de un array</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Para borrar todos los elementos de un array que cumplan con determinada condición ruby nos ofrese delete_if, este metodo se utiliza de la siguiente forma&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;[1,2, 10, 20].delete_if { |element| element &gt; 10}  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Esta operación nos eliminara del array todos los elementos mayores que 10 en este caso el 20, el resultado de este metodo es otro array con el resultado de la operacion en nuestro caso [1,2,10]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Otro ejemplo podria ser el siguiente&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;["a", "z", "d", "h"].delete_if { |element| element &gt; "a"} &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Esto nos retornaria un array cuyo unico elemento es la "a"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-6882121719812069035?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/6882121719812069035/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=6882121719812069035&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/6882121719812069035'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/6882121719812069035'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/borrar-elementos-de-un-array.html' title='Borrar elementos de un array'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-4149593229613986792</id><published>2008-10-25T19:28:00.012-02:00</published><updated>2008-11-28T10:56:08.322-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Migrations'/><title type='text'>Que son y como hacerlas</title><content type='html'>&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Las migrations son archivos escritos en codigo ruby que nos definen nuestro esquema de base de datos cada una es una parte de la base, en las migrations puede haber tanto codigo para crear tablas o modificarlas, como ingreso de datos o cualquier otra cosa que necesitemos en nuestro esquema como por ejemplo un indice. Se debe tratar de que cada migration sea atómica es decir hay que tratar de no modificar o crear mas de una tabla por migration, esto se hace por el hecho de que si falla una parte de una migration hay que volverla para atras y si escribimos por ejemplo la creación de dos tablas, y tenemos un error en la segunda, la primera tabla ya se creo pero falló la migration por lo cual cuando tratemos de correr nuevamente la migration, está nos va a dar un error ya que la primera tabla ya existe, entonces debemos ir a la base de datos y borrarla lo cual no es muy comodo.&lt;br /&gt;&lt;br /&gt;En cada migration de definen dos metodos principales el self.up y el self.down, la idea es que en el self.up escribas el codigo necesario para la creación de una tabla el modificiado o lo que sea que desees hacer en esa migration y en el self.down escribas el codigo necesario para revertir ese cambio, a continuacion voy a poner una lista con las operaciones que se pueden realizar en las migrations:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Table Options (table 1.1):&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;string (crea una campo del tipo string)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;boolean (crea un campo del tipo boolean)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;integer (crea un campo del tipo integer)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;float (crea un campo del tipo float)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;date (crea un campo del tipo date)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;datetime (crea un campo del tipo datetime)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;remove (quita un campo de la tabla, se utiliza solo para el change_table)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;references (crea un campo utilizando el nombre del campo + "_id")&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;remove_references (quita un campo que tiene el nombre del campo + "_id")&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;change (cambia un campo, solo se utiliza para el change_table)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;change_default (cambia el valor por defecto de un campo)&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;index (crea un indice para un atributo de la tabla)&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;remove_index (quita un indice a determinado atributo)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;timestamp (crea dos campos un es created_at y otro updated_at)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;remove_timestamps (quita dos campos created_at y updated_at, solo se utilza en el change_table)&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;rename (cambia el nombre del atributo)&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;create_table&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;br /&gt;create_table nombre_de_tabla opciones_de_creacion do |table|&lt;br /&gt;   table.options nombre_del_campo, aditional_options&lt;br /&gt;end&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;En options puede ir cualquiera de las opciones que esta dentro de &lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;table 1.1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;En opciones_de_creacion puede ir cualquiera de las siguientes opciones&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; -&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Por defecto esta true, si esta en true crea un atributo con el nombre id y el tipo integer&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="  ;font-family:Georgia;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;primary_key&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; - &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Por defecto toma como primary_key al id, pero se le puede indicar cualquier campo&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;de &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="  ;font-family:Georgia;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;force&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; - &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Por defecto esta en false, si esta en true nos indica que se cree la tabla aunque exista,&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;en false indica lo contrario&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="  ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Nota: &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; - Por defecto crea la primary key como id se pude cambiar utilizando las opciones.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Ejemplos &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);   "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;create_table :users do |table|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.string :nombre&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.date :fecha_nacimiento&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.boolean :activo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);  "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Crea una tabla llamada users con los siguientes campos id como primary key, nombre del tipo string, fecha_nacimiento del tipo date, y activo del tipo boolean.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="  "&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);   "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;create_table :users, :id =&gt; false, :force =&gt; true do |table|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.string :nombre&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.date :fecha_nacimiento&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);   "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);  "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);  "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Crea una tabla llamada users (aunque ya exista) con los siguientes campos nombre del tipo string y fecha_nacimiento del tipo date.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="  color: rgb(0, 0, 153);font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 0);   font-family:Georgia;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;create_table :users, :id =&gt; false, :force =&gt; true do |table|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.string :nombre&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.date :fecha_nacimiento&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.references :event&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Crea una tabla llamada users (aunque ya exista) con los siguientes campos nombre del tipo string, fecha_nacimiento del tipo date y event_id del tipo integer.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 0);   font-family:Georgia;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;change_table&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;br /&gt;change_table nombre_de_tabla opciones_de_creacion do |table|&lt;br /&gt;   table.options nombre_del_campo, aditional_options&lt;br /&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;El change_table es basicamente igual que el create_table en cuanto a sus opciones (ver la &lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;tabla 1.1&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;), pero su accion es cambiar una tabla, esta debe existir.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Ejemplos&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:verdana;font-size:13px;"&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;change_table :users do |table|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.string :nombre, :default =&gt; "pepe"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.remove :fecha_nacimiento&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);   font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="  ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Este ejemplo agrega a la tabla users un campo nombre del tipo string que su valor por defecto es "pepe" y quita de la tabla el campo fecha de nacimiento (el mismo debe existir en la tabla).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'courier new';font-size:13px;"&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;change_table :users do |table|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.index :type&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);   font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.remove_references :event&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);   font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="  ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Este ejemplo crea un indice para el atributo type y quita el campo event_id.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'courier new';font-size:13px;"&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;change_table :users do |table|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);   font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.change_default :nombre, "raul"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.change :edad, :integer, :default =&gt; 0&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   table.timestamp&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);   font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153);  font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="  ;font-family:'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Este ejemplo cambia el tipo por defecto del campo nombre por "raul", cambia el tipo de edad para integer y le asigna el valor por defecto 0, y crea dos campos created_at y updated_at que indican cuando fue creado el usuario y cuando se modifico&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); font-family: 'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;drop_table&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;drop_table nombre_de_tabla&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;Esta sentencia nos permite eliminar una tabla&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;Ejemplo&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;drop_table :users&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style=" ;font-family:'courier new';font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-4149593229613986792?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/4149593229613986792/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=4149593229613986792&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/4149593229613986792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/4149593229613986792'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/que-son-y-como-hacerlas.html' title='Que son y como hacerlas'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-2947021042863436573</id><published>2008-10-25T14:25:00.003-02:00</published><updated>2008-10-25T14:34:45.770-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Migrations'/><title type='text'>Schema.rb</title><content type='html'>&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:verdana;font-size:100%;"&gt;El archivo schema.rb alamacena la estructura de la base de datos actual de tu sistema, este archivo es util para saber como tenemos la base de datos, pero tambien sierve para importar el archivo en caso de que ocurra un error en las migrations y no podamos volver para atras o para adelante el esquema&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;font-size:100%;"&gt;Para exportar la base de datos a al archivo schema.rb&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span hover_container="show_note_1829013" class="hover_target"   style="font-family:verdana;font-size:100%;"&gt;&lt;strong hover_container="show_note_1829013"&gt;&lt;span style="font-weight: normal;"&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;rake db_schema_dump&lt;/span&gt; (es recomendable correr este comando cada vez que corremos migrations )&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: normal;"&gt;Para importar a la base de datos el archivo schema.rb&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;strong style="font-weight: normal;" hover_container="show_note_1829013"&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;rake db_schema_import&lt;/span&gt; (es importante destacar que cuando ocurre algun error ejecutando este comando nos tenemos que fijar que en la creación de las tablas este la clausula &lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;:forece =&gt; true&lt;/span&gt;)&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span hover_container="show_note_1829013" class="hover_target"&gt;&lt;strong hover_container="show_note_1829013"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-2947021042863436573?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/2947021042863436573/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=2947021042863436573&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/2947021042863436573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/2947021042863436573'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/schemarb.html' title='Schema.rb'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-9085728768210498395</id><published>2008-10-24T09:51:00.003-02:00</published><updated>2008-10-24T14:39:38.629-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lo basico'/><title type='text'>Estructura de un proyecto rails</title><content type='html'>Ahoara vamos a mostrar de que se compone la estructura basica de un proyecto en rails&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;App - &lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Aquí es donde va a estar el código fuerte de nuestra aplicación&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; line-height: 17px;"&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Config - &lt;/span&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Este directorio contiene la configuración de las bases de datos que vamos a utilizar en nuestra aplicación y de sus entornos de ejecución, rails propone tres entornos por defecto los cuales son desarrollo, test y producción.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; line-height: 17px;"&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Db - &lt;/span&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Aquí se almacenan las migrations, que son archivos que te ayudan a construir o reconstruir tu base de datos.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; line-height: 17px;"&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Doc - &lt;/span&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Este directorio se utiliza para documentación de tu aplicación, puedes hacerlo utilizando el comando rake&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; line-height: 17px;"&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Lib - &lt;/span&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Código escrito en Ruby al cual podremos acceder desde cualquier lugar de nuestra aplicación.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; line-height: 17px;"&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Log - &lt;/span&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;En este directorio se almacenaran los log del servidor para los distintos entornos de tu aplicación.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; line-height: 17px;"&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Public - &lt;/span&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Es el directorio del servidor web donde se encuentra todo el contenido estático de la aplicación, también se encuentran los dispatcher en este directorio.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; line-height: 17px;"&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Script - &lt;/span&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Contiene scripts que se utilizan para generar código rails.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; line-height: 17px;"&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Test - &lt;/span&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Directorio en el que se almacenan las pruebas unitarias, funcionales y de integración que se utilizan para probar la aplicación&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: Calibri; font-size: 15px; line-height: 17px;"&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Vendor - &lt;/span&gt;&lt;span lang="ES-TRAD" style="font-size:11.0pt;line-height: 115%;font-family:&amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;;mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font: minor-latin;mso-bidi-font-family:&amp;quot;Times New Roman&amp;quot;;mso-bidi-theme-font:minor-bidi; mso-ansi-language:ES-TRAD;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"&gt;Directorio en el que se encuentran los plugins que utilicemos para nuestra aplicación.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-9085728768210498395?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/9085728768210498395/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=9085728768210498395&amp;isPopup=true' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/9085728768210498395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/9085728768210498395'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/estructura-de-un-proyecto-rails.html' title='Estructura de un proyecto rails'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-667846039043182465</id><published>2008-10-23T14:46:00.001-02:00</published><updated>2008-10-24T09:28:19.343-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Arreglos'/><title type='text'>Iterar un array con los indicies</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ruby tiene una funcion que nos permite recorrer un array o un hash, esta función lo que hace es devolvernos los elementos y el indice en el cual se encuentran estos elementos.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;["a", "b", "1"].each_with_index do |elemento, indice|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;  &lt;/span&gt;"Aca hacemos lo que queremos con el elemento #{elemento} y con el indice #{indice}"&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-667846039043182465?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/667846039043182465/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=667846039043182465&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/667846039043182465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/667846039043182465'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/iterar-un-array-con-los-indicies.html' title='Iterar un array con los indicies'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-2453927695599640367</id><published>2008-10-23T09:10:00.002-02:00</published><updated>2008-10-23T09:18:06.669-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Arreglos'/><title type='text'>Como eliminar elementos repetidos</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Se pueden utilizar funciones ya predefinidas para eliminar los elementos repetidos de un array, las dos funciones que se pueden utilizar son las siguientes unique y unique!, ambas aplican sobre un arreglo&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;unique se utiliza para eliminar los elementos repetidos de un arreglo y retorna el arreglo resultante &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;[1,1,2,2,3].unique =&gt; [1,2,3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;unique! se utiliza para eliminar los elementos repetidos en un arreglo (aplican sobre el arreglo mismo), y retorna nil en caso de que no alla ningun elemento repetido y los elementos unicos cuando ocurre lo contrario&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;[1,1,4,5,4].unique! =&gt; [1,4,5]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;[1,2,3,4].unique! =&gt; nil &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-2453927695599640367?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/2453927695599640367/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=2453927695599640367&amp;isPopup=true' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/2453927695599640367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/2453927695599640367'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/como-eliminar-elementos-repetidos.html' title='Como eliminar elementos repetidos'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-7746626669853262214</id><published>2008-10-22T09:07:00.002-02:00</published><updated>2008-10-22T09:20:08.337-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Arreglos'/><title type='text'>Como borrar los elementos nil de un arreglo</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Cuando queremos eliminar todos los elementos nulos(nil) de un arreglo podemos utilizar la funcion compact o compact!&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;compact se aplica sobre un array y nos retorna un array sin los elementos nil&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;[1, nil, "a"].compact =&gt; [1, "a"]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;compact! también se aplica sobre un array, lo que hace es remover todos los elementos nil del mismo(los cambios se realizan sobre el array que estamos utilizando) y retorna los elementos del array que quedaron o nil en caso de que no alla ningun cambio&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;[2, 4, 8].compact! =&gt; nil&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;[2, nil, 8, nil].compact! =&gt; [2, 8]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-7746626669853262214?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/7746626669853262214/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=7746626669853262214&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/7746626669853262214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/7746626669853262214'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/como-borrar-los-elementos-nil-de-un.html' title='Como borrar los elementos nil de un arreglo'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-7060067582984055621</id><published>2008-10-21T09:21:00.002-02:00</published><updated>2008-10-21T09:38:48.069-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lo basico'/><title type='text'>Como generar un proyecto en rails</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Para generar un proyecto en rails (se asume que ya se tiene instalador rails de manera correcta), lo unico que debemos hacer es abrir una ventana de comandos en windows o linux, posicionarnos donde queremos crear el proyecto y luego escribir lo siguiente &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;rails nombre_del_proyecto, &lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;esto nos genera la estructura basica de un proyecto en rails.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-7060067582984055621?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/7060067582984055621/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=7060067582984055621&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/7060067582984055621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/7060067582984055621'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/como-generar-un-proyecto-en-rails.html' title='Como generar un proyecto en rails'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-2764315477111277633</id><published>2008-10-17T09:28:00.002-02:00</published><updated>2008-10-20T11:24:48.554-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Lo basico'/><title type='text'>Instalar Ruby on Rails WinXP</title><content type='html'>&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Como instalar ruby:&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Descargamos la ultima version de ruby del siguiente link &lt;/span&gt;&lt;/span&gt;&lt;a href="http://rubyforge.org/frs/?group_id=167&amp;amp;release_id=6163"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;rubyforge&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;, de ese link descargamos el .exe que tiene la instalación.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Una vez que descargamos el archivo lo ejecutamos y damos siguiente en hasta que se finalize la instalación (cuando nos pide los componentes que deseamos instalar seleccionamos todos)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;Para comprobar que la instalación se ha realizado correctamente ingresamos en una consola de windows(tecla de windows + R y tipeamos cmd enter), alli escribimos &lt;span class="Apple-style-span" style="font-size: 12px; "&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: georgia;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;ruby -version&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Como instalar rails:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Para instalar rails abrimos la consola de la misma manera que en el paso 3 de la instalación de ruby y escribimos &lt;/span&gt;&lt;/span&gt;&lt;kbd&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;gem install rails --include-dependencies &lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;y luego enter.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/kbd&gt;&lt;/li&gt;&lt;li&gt;&lt;kbd&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span" style="font-style: normal;"&gt;Si deseas comprobar que se ha instalado correctamente typea en la consola rails test, eso te deberia generar una proyecto rails vacio.&lt;/span&gt; &lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/kbd&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-2764315477111277633?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/2764315477111277633/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=2764315477111277633&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/2764315477111277633'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/2764315477111277633'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/instalar-ruby-on-rails-winxp.html' title='Instalar Ruby on Rails WinXP'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-3671455921334363249</id><published>2008-10-16T14:22:00.002-02:00</published><updated>2008-10-16T14:28:04.570-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='yield'/><title type='text'>yield y content_for</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Cuando deseamos mostrar contenido variable en una layout o en una vista podemos utilizar la sentencia yield de la siguiente manera&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;En el layout (en donde queremos que este el contenido variable):&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); font-family: 'courier new'; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;yield :contenido_variable &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); font-family: 'courier new'; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;En la vista es donde vamos a definir el contenido para la seccion variable de la siguiente manera&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: verdana; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span" style="font-family: 'courier new';"&gt;content_for :contenido_variable do&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); font-family: 'courier new'; font-size: 13px;"&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;contenido que deseemos&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); font-family: 'courier new'; font-size: 13px;"&gt;end&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); font-family: 'courier new'; font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: 13px; "&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;De esta manera podemos definir el contenido de una sección dependiendo de la vista en la que nos encontremos.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-3671455921334363249?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/3671455921334363249/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=3671455921334363249&amp;isPopup=true' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/3671455921334363249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/3671455921334363249'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/yield-y-contentfor.html' title='yield y content_for'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-2748382074507801172</id><published>2008-10-15T16:12:00.003-02:00</published><updated>2008-10-31T10:42:46.791-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Validaciones'/><category scheme='http://www.blogger.com/atom/ns#' term='Modelo'/><title type='text'>Validar largo de campo (validates_length_of)</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Cuando deseamos validar el lago de los campos dentro del modelo lo que debemos hacer es agregarle al modelo la siguiente línea&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;validates_length_of :atributo_a_validar, :opciones&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;Cuando el atributo al que se le desea validar el largo no cumple con lo que se le especifica en las opciones el mismo es agregado a una lista de errores que tiene el objeto del modelo.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;:atributo_a_validar - es el atributo al cual deseamos validarle el largo &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;:opciones - las opciones deben ir separadas por comas&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpFirst" style="text-indent:-18.0pt;mso-list:l0 level1 lfo1"&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;:allow_nil =&gt; true o false, indica si el objeto acepta valores nulos o no.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;:allow_blank =&gt; true o false, nos indica si el campo puede o no estar en blanco.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;:in =&gt; numero_inicio..numero_fin, nos indica que el largo del campo debe ir estar entre el numero_inicio y el numero_fin.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;:minimum =&gt; tamaño, nos indica el tamaño mínimo que puede tener el campo que se va a evaluar&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;: máximum =&gt; tamaño, nos indica el tamaño máximo&lt;/span&gt;&lt;/span&gt;&lt;span style="mso-spacerun:yes"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;que puede tener el campo que va&lt;/span&gt;&lt;/span&gt;&lt;span style="mso-spacerun:yes"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;a evaluar.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;:is =&gt; numero, nos indica el numero de caracteres que debe tener el campo.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;:message =&gt; mensaje, nos permite cambiar el mensaje que está asociado por defecto a el error, se puede utilizar %d dentro del nuevo mensaje de error para indicar el largo de la cadena que escribió el usuario.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;:too_long =&gt; mensaje, al igual que el anterior nos permite redefinir el mensaje de error para cuando el campo escrito es demasiado largo, también se puede utilizar %d.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style=" ;font-size:13px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:verdana;"&gt;:too_short =&gt; mensaje, al igual que los anteriores nos permite redefinir el mensaje de error para cuando el campo escrito es demasiado corto, también se puede utilizar %d.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-2748382074507801172?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/2748382074507801172/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=2748382074507801172&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/2748382074507801172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/2748382074507801172'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/validar-largo-de-campo.html' title='Validar largo de campo (validates_length_of)'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3452395458289460741.post-4375270920017702262</id><published>2008-10-15T13:55:00.006-02:00</published><updated>2008-10-16T14:21:45.792-02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Migrations'/><title type='text'>Ambiente en el cual correr migrations</title><content type='html'>&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Para seleccionar el ambiente en el cual deseas correr las migrations debes hacer lo siguiente:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;rake RAILS_ENV=enviroment db:migrate&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;enviroment puede ser cualquiera de los que se crea por defecto o cualquier ambiente creado por el usuario.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color: rgb(0, 0, 153); font-size:18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3452395458289460741-4375270920017702262?l=piconrails.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piconrails.blogspot.com/feeds/4375270920017702262/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3452395458289460741&amp;postID=4375270920017702262&amp;isPopup=true' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/4375270920017702262'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3452395458289460741/posts/default/4375270920017702262'/><link rel='alternate' type='text/html' href='http://piconrails.blogspot.com/2008/10/ambiente-en-el-cual-correr-migrations.html' title='Ambiente en el cual correr migrations'/><author><name>elpic</name><uri>http://www.blogger.com/profile/10971037115337847453</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
