<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>{ :ivan =&#62; :hq } &#187; Ruby on Rails</title>
	<atom:link href="http://ivanhq.net/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://ivanhq.net</link>
	<description>Unix, tecnología y algunas cosas sobre mí</description>
	<lastBuildDate>Sat, 18 Feb 2012 01:48:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Nosql con Redis y Mongodb</title>
		<link>http://ivanhq.net/2011/02/20/nosql-con-redis-y-mongodb/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nosql-con-redis-y-mongodb</link>
		<comments>http://ivanhq.net/2011/02/20/nosql-con-redis-y-mongodb/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 01:19:47 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[maresmedev]]></category>
		<category><![CDATA[nosql]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=541</guid>
		<description><![CDATA[Para quien no lo sepa, desde Noviembre de 2010 se viene celebrando una reunión mensual de programadores, sysadmins, diseñadores y en general gente técnica o creativa de la comarca del Maresme. Se le dio el nombre de Maresme Developers Meetup, y tiene su hashtag en Twitter: #maresmedev. Tenemos un grupo en Googlegroups al que cualquiera [...]]]></description>
			<content:encoded><![CDATA[<p>Para quien no lo sepa, desde Noviembre de 2010 se viene celebrando una reunión mensual de programadores, sysadmins, diseñadores y en general gente técnica o creativa de la comarca del Maresme. Se le dio el nombre de <strong>Maresme Developers Meetup</strong>, y tiene su hashtag en Twitter: <a href="http://twitter.com/#search?q=%23maresmedev">#maresmedev</a>.<br />
Tenemos un <a href="http://groups.google.com/group/maresmedev">grupo en Googlegroups</a> al que cualquiera se puede suscribir si desea conocer las fechas de las próximas reuniones y de lo que en ellas se va a hablar, y en breve montaremos un site, quizá un blog, en el que colgar los slides y vídeos de las techtalks.<br />
Por el momento nos comunicamos por Twitter y en la mailing, y las slides las compartimos en Slideshare.</p>
<p>La última reunión tuvo lugar ayer (viernes 18 de Febrero de 2011), y la charla corría a mi cargo. Era una pequeña presentación del <a href="http://en.wikipedia.org/wiki/NoSQL">movimiento Nosql</a>, haciendo un ligero repaso por encima a <a href="http://redis.io">Redis</a> y a <a href="http://mongodb.org">Mongodb</a>.</p>
<p>En realidad yo no sé mucho sobre el tema. Se ha puesto de moda en los últimos dos años, y por pura curiosidad programé mi último proyecto (<a href="http://apps.facebook.com/fantastic_love">Fantastic Love Machine</a>) usando Rails 3 y Redis&#8230; símplemente con el ánimo de aprender.<br />
La buena prensa de Mongodb me llevó a indagar un poco hace un par de semanas, y después de ver cómo funciona y probar un Orm para Ruby llamado <a href="http://mongoid.org">Mongoid</a>, decidí migrar la aplicación.</p>
<p>El resultado es que ahora conozco un poquito como funcionan ambos sistemas, y aproveché el meetup mensual de la <a href="http://twitter.com/#search?q=%23maresmedev">#maresmedev</a> para presentar las cuatro cositas que he aprendido en este tiempo.</p>
<p>Y bueno&#8230; cómo no: aquí están los slides :-)</p>
<div align="center">
<div style="width:425px" id="__ss_6979520"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/ibelmonte/nosql-redismongo" title="Nosql redis-mongo">Nosql redis-mongo</a></strong><object id="__sse6979520" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=nosql-redis-mongo-110218214035-phpapp02&#038;stripped_title=nosql-redismongo&#038;userName=ibelmonte" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse6979520" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=nosql-redis-mongo-110218214035-phpapp02&#038;stripped_title=nosql-redismongo&#038;userName=ibelmonte" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/ibelmonte">ibelmonte</a>.</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2011/02/20/nosql-con-redis-y-mongodb/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fantastic Love Machine</title>
		<link>http://ivanhq.net/2010/12/27/fantastic-love-machine/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fantastic-love-machine</link>
		<comments>http://ivanhq.net/2010/12/27/fantastic-love-machine/#comments</comments>
		<pubDate>Mon, 27 Dec 2010 01:55:43 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[proyectos]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=525</guid>
		<description><![CDATA[Los que me conocen saben que me da muchísima rabia programar aplicaciones para Facebook. Y en realiad no es porque me dé rabia Facebook como plataforma (soy twittero de corazón), sino porque el desarrollador está dejado de la mano de dios en cuanto a aplicaciones de Facebook se refiere. No obstante Facebook es la plataforma [...]]]></description>
			<content:encoded><![CDATA[<p>Los que me conocen saben que me da muchísima rabia programar aplicaciones para Facebook. Y en realiad no es porque me dé rabia Facebook como plataforma (soy twittero de corazón), sino porque el desarrollador está dejado de la mano de dios en cuanto a aplicaciones de Facebook se refiere.</p>
<p>No obstante Facebook es la plataforma ideal para lanzar proyectos que requieren una capa social. Y esto es <a href="http://apps.facebook.com/fantastic_love">Fantastic Love Machine</a>.</p>
<p><a href="http://www.facebook.com/pages/Fantastic-Love-Machine/184107698282890?v=app_7146470109"><img src="http://ivanhq.net/wp-content/uploads/2010/12/fantastic_love.jpg" alt="" title="fantastic_love" width="477" height="400" class="aligncenter size-full wp-image-528" /></a></p>
<p>Se trata de una aplicación que permite al usuario encontrar amantes (o una pareja estable, allá cada cual heheh) entre su círculo habitual de amigos. Funciona de la siguiente manera:</p>
<ul>
<li>El usuario instala la aplicación, y elige las amigas o amigos que le gustan.</li>
<li>Los amigos y amigas hacen el mismo proceso</li>
<li>Si el usuario ha marcado a una chica, y a su vez ella también le ha marcado a él, la aplicación les avisa a los dos en secreto</li>
</ul>
<p>Es una aplicación divertida y seguro que a más de uno le ayuda a encontrar novia&#8230; o algún ligue asegurado heheh</p>
<p>Como anécdota comentar que la he desarrollado en Rails 3, y como base de datos he usado Redis en lugar de Mysql para experimentar. De momento no he usado ningún ORM, aunque viendo la dificultad de realizar búsquedas entre los documentos ya le tengo echado el ojo a <a href="http://ohm.keyvalue.org/">Ohm</a>, y se lo implementaré en breve.</p>
<p>Más info en <a href="http://www.facebook.com/pages/Fantastic-Love-Machine/184107698282890?v=app_7146470109">la fanpage de <strong>FLM</strong> en Facebook</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2010/12/27/fantastic-love-machine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Set up a full development server for a Ruby on Rails project</title>
		<link>http://ivanhq.net/2010/09/08/set-up-a-full-development-server-for-a-ruby-on-rails-project/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=set-up-a-full-development-server-for-a-ruby-on-rails-project</link>
		<comments>http://ivanhq.net/2010/09/08/set-up-a-full-development-server-for-a-ruby-on-rails-project/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 13:19:03 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=474</guid>
		<description><![CDATA[Those who know me also know that one thing I&#8217;m specially concerned about is the importance of writing good documentation on everything you do. Specially for technical projects. Maybe it is not important for coders or designers, but for a sysadmin I think it should be definilety mandatory. If you get cool things working together [...]]]></description>
			<content:encoded><![CDATA[<p>Those who know me also know that one thing I&#8217;m specially concerned about is the importance of writing good documentation on everything you do. Specially for technical projects. Maybe it is not important for coders or designers, but for a sysadmin I think it should be definilety mandatory. If you get cool things working together but you don&#8217;t write any documentation, you won&#8217;t be able to play that music again.</p>
<p>Also, I am working in Ruby on Rails development since about 2 years ago. One of the things I have to do usually is to set up servers for hosting projects. And sometimes I have to set up a server for project development and tracking. These are the steps you can follow to set up a Ruby on Rails based server for development tracking.</p>
<p><b>1. Get a server</b></p>
<p>There are plenty of choices around the internet, some of them come completelly installed and prepared for deploying your app. They usually work the same way traditional LAMP hostings used to do, but using ssh key authentication instead of FTP sessions&#8230; some of them have also  web based backend panels for deploying, migrating and managing your app gems. </p>
<p>I prefer to set up an empty GNU/Linux vanilla server, so that I can host everything I need, my way, no worries if PHP, Ruby or whatever. I can set up a relay mailserver, netfilter routing, traffic shaping, services for monitoring and differential backups that I can periodically rsync to my office local server. This is the way a sysadmin thinks, something that coders not always understand.</p>
<p>If you want to set up a development server I recomment you to take a look at most basic <a href="http://linode.com">Linode VPS</a>. Their control panel will let you run and destroy any Linux distro, setup and resize partitions, add failover addresses, disk space, processor and memory. And of course you&#8217;ll have full SSH root access. So I find it very useful and flexible for my needs.</p>
<p>Some considerations:</p>
<ul>
<li>You&#8217;ll have to <b>set up a DNS name for the server IP</b>, i.e: <b>http://devel.somedomain.net</b></li>
<li>You&#8217;ll need root access on the server. I&#8217;ll suppose you are working on a local computer, remotely logged via SSH to your server</li>
<li>I usually build my servers using Debian (<i>Lenny</i> for now), but a basic knowledge of any other distro package system will let you adapt my guide to your preferred system</li>
<li>I&#8217;ll suppose you&#8217;ve set up a specific environment for running your app on the development server (I usually call it <i>beta</i>)</li>
</ul>
<p><b>2. Install screen</b></p>
<p>You may partially lose your work if for any reason your local computer hangs during the process. So it&#8217;s recommendable to install and use screen for working on a detachable console terminal. This way, if your computer shuts down, you&#8217;ll be able to boot again, ssh into your server and recover your screen session.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> <span style="color: #c20cb9; font-weight: bold;">screen</span></div></div>
<p>You&#8217;ll maybe want to set up your screen sessions to look nicer than withe on black, and give you some additional information of the remote system. I use a copy of the screenrc configuration file from my friend <a href="http://userlinux.net">r0sk</a>, it&#8217;s simple and nice and works sweet.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-c</span> http:<span style="color: #000000; font-weight: bold;">//</span>ivanhq.net<span style="color: #000000; font-weight: bold;">/</span>stuff<span style="color: #000000; font-weight: bold;">/</span>_screenrc<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> _screenrc ~<span style="color: #000000; font-weight: bold;">/</span>.screenrc</div></div>
<p>Enter screen</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">screen</span></div></div>
<p><b>3. Base system</b></p>
<p>You&#8217;ll need an unprivileged user to host your web apps. I usually create a <i>web</i> user</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<br />
groupadd service<br />
useradd <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-g</span> service web<br />
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> web:service <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #c20cb9; font-weight: bold;">passwd</span> web &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># type your preferred password here</span></div></div>
<p>Add <i>contrib</i> and <i>non-free</i> repositories to your Apt sources file (<b>vim /etc/apt/sources.list</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">deb http:<span style="color: #000000; font-weight: bold;">//</span>ftp.us.debian.org<span style="color: #000000; font-weight: bold;">/</span>debian lenny main contrib non-free<br />
deb-src http:<span style="color: #000000; font-weight: bold;">//</span>ftp.us.debian.org<span style="color: #000000; font-weight: bold;">/</span>debian lenny main contrib non-free</div></div>
<p>Update your sources and then your system</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get update</span><br />
<span style="color: #c20cb9; font-weight: bold;">apt-get upgrade</span></div></div>
<p>Edit your SSH server config file to disallow root login and enable SSH key authentication (<b>vim /etc/ssh/sshd_config</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># change next line, swap &quot;yes&quot; for &quot;no&quot;</span><br />
PermitRootLogin no<br />
&nbsp;<br />
<span style="color: #666666; font-style: italic;"># uncomment next line</span><br />
AuthorizedKeysFile &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">%</span>h<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</div></div>
<p>Restart your SSH service</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> restart</div></div>
<p>Install build-essentials for compiling and installing the environment dependencies</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> build-essential</div></div>
<p>Install Postfix for using as MTA relay server, or MySQL Debian packages will install Exim (which I don&#8217;t really like)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> postfix<br />
<br />
<span style="color: #666666; font-style: italic;"># select: internet site</span><br />
<span style="color: #666666; font-style: italic;"># MTA's outgoing domain name: somedomain.net</span></div></div>
<p><b>4. Backports</b></p>
<p>Because of some software versions being old and deprecated on the APT sources, and some other not being present, an alternative repository can be set up for installing newer versions. The backports repository.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-O</span> - http:<span style="color: #000000; font-weight: bold;">//</span>backports.org<span style="color: #000000; font-weight: bold;">/</span>debian<span style="color: #000000; font-weight: bold;">/</span>archive.key <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">apt-key add</span> -</div></div>
<p>Edit your APT sources file (<b>vim /etc/apt/sources.list</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">deb http:<span style="color: #000000; font-weight: bold;">//</span>www.backports.org<span style="color: #000000; font-weight: bold;">/</span>debian lenny-backports main contrib non-free</div></div>
<p>Update your system again</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get update</span></div></div>
<p><b>5. MySQL</b></p>
<p>Install <b>mysql</b> service, and its ruby bindings package</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> mysql-server mysql-client libmysqlclient15-dev libmysql-ruby</div></div>
<p>Create a database for your project (<b>mysql -uroot -p</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> CREATE DATABASE yourapp_beta;<br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> GRANT ALL PRIVILEGES ON yourapp_beta.<span style="color: #000000; font-weight: bold;">*</span> TO yourapp_username<span style="color: #000000; font-weight: bold;">@</span>localhost IDENTIFIED BY <span style="color: #ff0000;">'your_superhacker_password123'</span>;</div></div>
<p><b>6. Ruby, Rubygems and Rails</b></p>
<p>Install the Ruby stuff, I prefer to use backports at this point to ensure latest versions.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #660033;">-t</span> lenny-backports <span style="color: #c20cb9; font-weight: bold;">install</span> ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby</div></div>
<p>Add unversioned links for the newly created binaries</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby<br />
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ri1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ri<br />
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rdoc1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rdoc<br />
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>irb1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>irb<br />
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem</div></div>
<p>Install Rubygems from source, so you can update it directly whenever you want. Otherwise the system will update it for you, only when new packages for your distro are available.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src<br />
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-c</span> http:<span style="color: #000000; font-weight: bold;">//</span>production.cf.rubygems.org<span style="color: #000000; font-weight: bold;">/</span>rubygems<span style="color: #000000; font-weight: bold;">/</span>rubygems-1.3.7.tgz<br />
<span style="color: #c20cb9; font-weight: bold;">tar</span> zxvfp rubygems-1.3.7.tgz<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> rubygems-1.3.7<br />
ruby setup.rb</div></div>
<p>Link <i>gem</i> binary to an unversioned name</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem</div></div>
<p>Update rubygems (not really needed, but just in case)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem update<br />
gem update <span style="color: #660033;">--system</span></div></div>
<p>Install Rails</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails</div></div>
<p><b>7. Image processing</b></p>
<p>Youll surelly want a plugin for cropping and thumbnailing images, maybe <i>attachment_fu</i> or <i>paperclip</i>. They both can work with Imagemagick.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> imagemagick</div></div>
<p><b>8. Apache</b></p>
<p>There are different web server layouts for hosting your application. Some people likes Nginx+Mongrel, some other prefer Apache+Passenger, others prefer Nginx+Passenger&#8230; I love Apache. Maybe because its syntax simplicity, its flexibility or maybe simply because as a sysadmin I&#8217;ve been working for years with it.</p>
<p>Install Apache</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> apache2.2-common apache2-mpm-prefork apache2-prefork-dev libssl-dev</div></div>
<p>Rename default virtualhost</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a2dissite default<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>default <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>devel_somedomain_net</div></div>
<p>Edit that virtualhost (<b>vim /etc/apache2/sites-available/devel_somedomain_net</b>)and configure it with the minimum options to work. I&#8217;m adding a basic HTTP authentication so only people you give the password can see your project (it&#8217;s a development server heheh).</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ServerName devel.somedomain.net<br />
&nbsp; &nbsp; &nbsp; &nbsp; RailsEnv beta<br />
&nbsp; &nbsp; &nbsp; &nbsp; DocumentRoot <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>devel.somedomain.net<span style="color: #000000; font-weight: bold;">/</span>current<span style="color: #000000; font-weight: bold;">/</span>public<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; CustomLog <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>devel_somedomain_net<span style="color: #000000; font-weight: bold;">/</span>access.log combined<br />
&nbsp; &nbsp; &nbsp; &nbsp; ErrorLog <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>devel_somedomain_net<span style="color: #000000; font-weight: bold;">/</span>error.log<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>devel_somedomain_net<span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AuthType Basic<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AuthName <span style="color: #ff0000;">&quot;Members Only&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AuthUserFile <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>.htpasswd_devel_somedomain_net<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;</span>limit GET PUT POST<span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; require valid-user<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/</span>limit<span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></div></div>
<p>Enable your new virtualhost</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a2ensite devel_somedomain_net</div></div>
<p>As the unprivileged user running the service, create the application directory and the HTTP Auth passwords file</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">su</span> - web<br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>devel.somedomain.net<br />
&nbsp;<br />
htpasswd <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>.htpasswd_devel_somedomain_net username1<br />
htpasswd <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>.htpasswd_devel_somedomain_net username2<br />
....<br />
<br />
<span style="color: #7a0874; font-weight: bold;">exit</span></div></div>
<p>Create the apache log directory for your app</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>devel_somedomain_net</div></div>
<p>Install Passenger</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem <span style="color: #c20cb9; font-weight: bold;">install</span> passenger<br />
passenger-install-apache2-module</div></div>
<p>Create a file for loading passenger module into Apache (<b>vim /etc/apache2/mods-available/passenger.load</b>). Be careful with versions on the names as they may have changed.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">LoadModule passenger_module <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.15<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>mod_passenger.so<br />
PassengerRoot <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>passenger-2.2.15<br />
PassengerRuby <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby1.8</div></div>
<p>Enable passenger module</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a2enmod passenger</div></div>
<p>Change the user and group executing Apache service to match your unprivileged user (<b>vim /etc/apache2/envvars</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#export APACHE_RUN_USER=www-data</span><br />
<span style="color: #666666; font-style: italic;">#export APACHE_RUN_GROUP=www-data</span><br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">APACHE_RUN_USER</span>=web<br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">APACHE_RUN_GROUP</span>=service</div></div>
<p>Restart Apache</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</div></div>
<p><b>9. Git and Gitosis</b></p>
<p>If you don&#8217;t want to pay a Github account and you don&#8217;t want your source to be visible to everyone, you&#8217;ll want to host your own Git server. There are different choices for that, but I like Gitosis because it&#8217;s simple and I can manage it from my command line, only editing a config file.</p>
<p>Install Git</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #660033;">-t</span> lenny-backports <span style="color: #c20cb9; font-weight: bold;">install</span> git-arch</div></div>
<p>Gitosis is written in Python, so you need to install python&#8217;s setup-tools in order to install Gitosis</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> python-setuptools</div></div>
<p>Clone and install Gitosis</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src<br />
<span style="color: #c20cb9; font-weight: bold;">git clone</span> git:<span style="color: #000000; font-weight: bold;">//</span>eagain.net<span style="color: #000000; font-weight: bold;">/</span>gitosis.git<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> gitosis<br />
python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></div></div>
<p>Create a new unprivileged user for hosting Gitosis and its repositories. It does not need a password (so it can&#8217;t log in) but it needs a shell as all management occours using an SSH session.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">adduser \<br />
<span style="color: #660033;">--system</span> \<br />
<span style="color: #660033;">--shell</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> \<br />
<span style="color: #660033;">--gecos</span> <span style="color: #ff0000;">'git version control'</span> \<br />
<span style="color: #660033;">--group</span> \<br />
<span style="color: #660033;">--disabled-password</span> \<br />
<span style="color: #660033;">--home</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">git</span> \<br />
<span style="color: #c20cb9; font-weight: bold;">git</span><br />
&nbsp;<br />
usermod <span style="color: #660033;">-g</span> service <span style="color: #c20cb9; font-weight: bold;">git</span></div></div>
<p>Upload your ssh public key to the server, leave it in /tmp/ and call it <b>user@host.pub</b> being <i>user@host</i> the final string specified into the file itself (<i>ivan@mbp-local</i>, or something similar)</p>
<p>Initialize Gitosis using the SSH key you just uploaded, which will be the Gitosis admin</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">su</span> - <span style="color: #c20cb9; font-weight: bold;">git</span><br />
gitosis-init <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ivan\<span style="color: #000000; font-weight: bold;">@</span>ibelmonte-mbp.local.pub</div></div>
<p><b>In your local computer</b> clone the Gitosis repository so you can manage it from now on</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">git clone</span> <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>devel.somedomain.net:gitosis-admin.git</div></div>
<p>Enter the </i>gitosis-admin</i> directory and check the contents. It has to show a filename called <i>gitosis.conf</i> and a directory called <i>keydir</i>.</p>
<p><b>10. Add a repository for your app</b></p>
<p>Edit the Gitosis config (<b>vim gitosis.conf</b>) and add a new group, formed with one user (or more, separated with spaces), and its repository</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">&#91;</span>group your_app_name<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
members = user1<span style="color: #000000; font-weight: bold;">@</span>host1 user2<span style="color: #000000; font-weight: bold;">@</span>host2 ...<br />
writable = your_repo_name</div></div>
<p>Make sure to put user&#8217;s keyfiles into the <i>keydir</i> directory, following the previously mentioned format. Upload your changes.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">git add</span> .<br />
<span style="color: #c20cb9; font-weight: bold;">git commit</span> <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Added user2 to your_app group&quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">git push</span></div></div>
<p><b>In your local computer</b> you can now create an application and add its files to the repo</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rails your_app<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> your_app<br />
<span style="color: #c20cb9; font-weight: bold;">git init</span><br />
<span style="color: #c20cb9; font-weight: bold;">git remote</span> add origin <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>devel.somedomain.net:your_app.git<br />
<span style="color: #c20cb9; font-weight: bold;">git add</span> .<br />
<span style="color: #c20cb9; font-weight: bold;">git commit</span> <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Initial import&quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">git push</span> origin master:refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>master</div></div>
<p><b>11. Capistrano</b></p>
<p>You&#8217;ll want to deploy your software to your newly configured server. Capistrano is the best choice I know, since it creates versioned directories to let you roll back and forth, remotely run tasks on the hosted version of your app, place a custom &#8220;under maintenance&#8221; page, etc&#8230;</p>
<p>Install Capistrano</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">gem <span style="color: #c20cb9; font-weight: bold;">install</span> capistrano</div></div>
<p>Capify your application</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>your<span style="color: #000000; font-weight: bold;">/</span>app<br />
capify .</div></div>
<p>Create a recipe (<b>vim config/deploy.rb</b>)</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># set a target name, so you can also use it to deploy to a production server</span><br />
<br />
<span style="color:#008000; font-style:italic;"># set :targetname, 'www'</span><br />
set <span style="color:#ff3333; font-weight:bold;">:targetname</span>, <span style="color:#996600;">'devel'</span><br />
&nbsp;<br />
<span style="color:#9966CC; font-weight:bold;">if</span> targetname == <span style="color:#996600;">'devel'</span><br />
&nbsp; set <span style="color:#ff3333; font-weight:bold;">:rails_env</span>, <span style="color:#996600;">'beta'</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp;<br />
set <span style="color:#ff3333; font-weight:bold;">:application</span>, <span style="color:#996600;">&quot;#{targetname}.somedomain.net&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:deploy_to</span>, <span style="color:#996600;">&quot;/home/web/sites/#{application}&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:user</span>, <span style="color:#996600;">&quot;web&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:runner</span>, <span style="color:#996600;">&quot;web&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:repository</span>, <span style="color:#996600;">&quot;git@devel.somedomain.net:your_app.git&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:deploy_via</span>, <span style="color:#ff3333; font-weight:bold;">:remote_cache</span><br />
set <span style="color:#ff3333; font-weight:bold;">:copy_exclude</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;.git&quot;</span>, <span style="color:#996600;">&quot;.gitignore&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:scm</span>, <span style="color:#ff3333; font-weight:bold;">:git</span><br />
set <span style="color:#ff3333; font-weight:bold;">:use_sudo</span>, <span style="color:#0000FF; font-weight:bold;">false</span><br />
&nbsp;<br />
<span style="color:#008000; font-style:italic;"># Master branch of course. If not, change</span><br />
<span style="color:#008000; font-style:italic;">#</span><br />
<span style="color:#008000; font-style:italic;"># set :branch, master</span><br />
&nbsp;<br />
ssh_options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:forward_agent</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp;<br />
role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;#{targetname}.somedomain.net&quot;</span><br />
role <span style="color:#ff3333; font-weight:bold;">:web</span>, <span style="color:#996600;">&quot;#{targetname}.somedomain.net&quot;</span><br />
role <span style="color:#ff3333; font-weight:bold;">:db</span>, &nbsp;<span style="color:#996600;">&quot;#{targetname}.somedomain.net&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp;<br />
namespace <span style="color:#ff3333; font-weight:bold;">:deploy</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; desc <span style="color:#996600;">&quot;Restarting passenger with restart.txt&quot;</span><br />
&nbsp; task <span style="color:#ff3333; font-weight:bold;">:restart</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#ff3333; font-weight:bold;">:except</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:no_release</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; run <span style="color:#996600;">&quot;touch #{current_path}/tmp/restart.txt&quot;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp;<br />
&nbsp; <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:start</span>, <span style="color:#ff3333; font-weight:bold;">:stop</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; desc <span style="color:#996600;">&quot;#{t} task is a no-op with mod_rails&quot;</span><br />
&nbsp; &nbsp; task t, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:app</span> <span style="color:#9966CC; font-weight:bold;">do</span> ; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p><b>12. SSH keys</b></p>
<p>In order to deploy your app without typing any password, you&#8217;ll have to set up a SSH key authentication between you and the unprivileged user of the server (<i>web</i> user).</p>
<p>Copy the content of your local ssh keyfile (commonly ~/.ssh/<i>id_rsa.pub</i>) and paste at the end of <b>/home/web/.ssh/authorized_keys</b> on the server. You&#8217;ll want to repeat this process for each developer so they can also deploy without typing a password.</p>
<p>You&#8217;ll also need to generate a SSH key for your <i>web</i> user on the server, and add it as a member of the repo in gitosis. Otherwise you won&#8217;t be able to deploy your app, because the server won&#8217;t let itself access to the repo for fetching.</p>
<p><b>13. Redmine</b></p>
<p>Redmine is one of those powerful tools that make your life easier when working with other developers, designers, webmasters and CEO&#8217;s&#8230; it helps you to keep tracking of issues, bugs, timings, files and documents, wikis and it also lets you graphically browse your repositories. If you&#8217;ve never tested it, now it&#8217;s your time.</p>
<p><b>NOTE:</b> you&#8217;ll need to create a new entry on your DNS server. Set up a CNAME called <i>redmine</i> pointing to <i>devel.somedomain.net</i></p>
<p>Redmine needs mod_rewrite support on Apache</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a2enmod rewrite</div></div>
<p>You&#8217;ll need subversion to checkout the source code of Redmine</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get install</span> subversion</div></div>
<p>Su to your unprivileged user</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">su</span> - web</div></div>
<p>Checkout the code</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> sites<br />
<span style="color: #c20cb9; font-weight: bold;">svn co</span> http:<span style="color: #000000; font-weight: bold;">//</span>redmine.rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>tags<span style="color: #000000; font-weight: bold;">/</span>1.0.1<span style="color: #000000; font-weight: bold;">/</span> redmine.somedomain.net<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> redmine.somedomain.net</div></div>
<p>Create a database for redmine (<b>mysql -uroot -p</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> CREATE DATABASE redmine CHARACTER SET utf8;<br />
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> GRANT ALL PRIVILEGES ON redmine.<span style="color: #000000; font-weight: bold;">*</span> TO redmine<span style="color: #000000; font-weight: bold;">@</span>localhost IDENTIFIED BY <span style="color: #ff0000;">'redmine123'</span>;</div></div>
<p>Edit Redmine&#8217;s database configuration file (<b>vim config/database.yml</b>)</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">production:<br />
&nbsp; adapter: mysql<br />
&nbsp; database: redmine<br />
&nbsp; host: localhost<br />
&nbsp; username: redmine<br />
&nbsp; password: redmine123<br />
&nbsp; encoding: utf8<br />
&nbsp; socket: <span style="color:#006600; font-weight:bold;">/</span>var<span style="color:#006600; font-weight:bold;">/</span>run<span style="color:#006600; font-weight:bold;">/</span>mysqld<span style="color:#006600; font-weight:bold;">/</span>mysqld.<span style="color:#9900CC;">sock</span></div></div>
<p>Place a secret key for Redmine cookies on its environment file, inside the <i>Initializer</i> block (<b>vim config/environment.rb</b>)</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">session</span> = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:key</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;_redmine_somedomain_com_session&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:secret</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;578359e95c3f2sj9enw10amkd81508ff&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div></div>
<p>Migrate the database</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">RAILS_ENV</span>=production rake db:migrate</div></div>
<p>Edit the SMTP configuration for Redmine to be able to send notification emails (<b>vim config/email.yml</b>)</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">production:<br />
&nbsp; delivery_method: <span style="color:#ff3333; font-weight:bold;">:smtp</span><br />
&nbsp; smtp_settings:<br />
&nbsp; &nbsp; address: <span style="color:#996600;">&quot;smtp.somedomain.net&quot;</span><br />
&nbsp; &nbsp; port: <span style="color:#996600;">'25'</span><br />
&nbsp; &nbsp; domain: <span style="color:#996600;">&quot;somedomain.net&quot;</span><br />
&nbsp; &nbsp; authentication: <span style="color:#ff3333; font-weight:bold;">:login</span><br />
&nbsp; &nbsp; user_name: <span style="color:#996600;">&quot;your_username&quot;</span><br />
&nbsp; &nbsp; password: <span style="color:#996600;">&quot;your_password&quot;</span></div></div>
<p>If you want to relay over Gmail or your domain&#8217;s email is hosted on Google apps, you&#8217;ll need to install a tls authentication plugin</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ruby script<span style="color: #000000; font-weight: bold;">/</span>plugin <span style="color: #c20cb9; font-weight: bold;">install</span> git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>collectiveidea<span style="color: #000000; font-weight: bold;">/</span>action_mailer_optional_tls.git</div></div>
<p>Use this config for use with Gmail / Google apps</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">production:<br />
&nbsp; delivery_method: <span style="color:#ff3333; font-weight:bold;">:smtp</span><br />
&nbsp; smtp_settings:<br />
&nbsp; &nbsp; tls: <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp; &nbsp; address: <span style="color:#996600;">&quot;smtp.gmail.com&quot;</span><br />
&nbsp; &nbsp; port: <span style="color:#996600;">'587'</span><br />
&nbsp; &nbsp; domain: <span style="color:#996600;">&quot;gmail.com&quot;</span> &nbsp; <span style="color:#008000; font-style:italic;"># use &quot;somedomain.net&quot; in case of Google Apps</span><br />
&nbsp; &nbsp; authentication: <span style="color:#ff3333; font-weight:bold;">:plain</span><br />
&nbsp; &nbsp; user_name: <span style="color:#996600;">&quot;your_username&quot;</span><br />
&nbsp; &nbsp; password: <span style="color:#996600;">&quot;your_password&quot;</span></div></div>
<p>Exit su, and become root again</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">exit</span></div></div>
<p>Create a new Apache virtualhost (<b>vim /etc/apache2/sites-available/redmine_somedomain_net</b>)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ServerName redmine.somedomain.net<br />
&nbsp; &nbsp; &nbsp; &nbsp; RailsEnv production<br />
&nbsp; &nbsp; &nbsp; &nbsp; DocumentRoot <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>sites<span style="color: #000000; font-weight: bold;">/</span>redmine.somedomain.net<span style="color: #000000; font-weight: bold;">/</span>public<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; CustomLog <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>redmine_somedomain_net<span style="color: #000000; font-weight: bold;">/</span>access.log combined<br />
&nbsp; &nbsp; &nbsp; &nbsp; ErrorLog <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>redmine_somedomain_net<span style="color: #000000; font-weight: bold;">/</span>error.log<br />
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></div></div>
<p>Create an Apache log directory for redmine</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>redmine_somedomain_net<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p>Enable your new virtualhost and restart Apache</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a2ensite redmine.somedomain.net<br />
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</div></div>
<p><b>14. Start writing Ruby on Rails</b></p>
<p>Here comes the funny part. Enjoy! ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2010/09/08/set-up-a-full-development-server-for-a-ruby-on-rails-project/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tip: recover to_xml serialized latin chars</title>
		<link>http://ivanhq.net/2010/03/24/tip-recover-to_xml-serialized-latin-chars/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tip-recover-to_xml-serialized-latin-chars</link>
		<comments>http://ivanhq.net/2010/03/24/tip-recover-to_xml-serialized-latin-chars/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 01:21:54 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=371</guid>
		<description><![CDATA[I am generating an XML file for dumping some data from one application to another. Yes, I know it&#8217;s nicer to build a RESTful API, but it&#8217;s for a very custom scenario and the shorter way is to write an XML based interface. So I simply export some contents: def show_some_content &#160; @content = Content.find&#40;:all&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>I am generating an XML file for dumping some data from one application to another. Yes, I know it&#8217;s nicer to build a RESTful API, but it&#8217;s for a very custom scenario and the shorter way is to write an XML based interface. So I simply export some contents:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">def</span> show_some_content<br />
&nbsp; <span style="color:#0066ff; font-weight:bold;">@content</span> = Content.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span><span style="color:#CC0066; font-weight:bold;">format</span><span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>For my view:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#0066ff; font-weight:bold;">@content</span>.<span style="color:#9900CC;">to_xml</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></div></div>
<p>The problem then is the resulting XML has not only escaped the HTML entities, but also latin characters (ie accents and tildes). After googling for an hour I&#8217;ve found some people blaming <b><i>to_xs</i></b> method (HTML escaped version of <b><i>to_s</i></b>, as its definition says) used for XML serialization.</p>
<p>Well, from the other app I need to parse this XML and get the original text. How the hell do I get latin chars unescaped again?</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cgi'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'iconv'</span><br />
<br />
encoded_text = <span style="color:#996600;">&quot;ram&amp;#243;n&quot;</span><br />
<span style="color:#008000; font-style:italic;"># some fucking encoded text coming from the XML</span><br />
<br />
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{Iconv.iconv('UTF-8', 'ISO-8859-1', CGI.unescapeHTML(encoded_text)).to_s}&quot;</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; &quot;ramón&quot;</span></div></div>
<p>That&#8217;s it :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2010/03/24/tip-recover-to_xml-serialized-latin-chars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Massive emailer</title>
		<link>http://ivanhq.net/2009/11/20/massive-emailer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=massive-emailer</link>
		<comments>http://ivanhq.net/2009/11/20/massive-emailer/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 13:04:10 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=320</guid>
		<description><![CDATA[Yesterday I did a talk at Xing offices in Barcelona. It was about some tips on how to send emails massively from a Ruby on Rails application without being tagged as a spammer by Hotmail, Gmail or Yahoo. I&#8217;m not a dedicated expert on this, but I&#8217;ve been learning these things while developing last internet [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I did a talk at Xing offices in Barcelona. It was about some tips on how to send emails massively from a Ruby on Rails application without being tagged as a spammer by Hotmail, Gmail or Yahoo. I&#8217;m not a dedicated expert on this, but I&#8217;ve been learning these things while developing last internet site, and I thought it may be also interesting for other developers.<br />
Here are the slides (in english) of the presentation, formerly named  &#8220;<b>Massive emailing with Linux, Postfix and Ruby on Rails</b>&#8220;.</p>
<div style="width:490px;text-align:center" id="__ss_2544347"><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=massiveemailer-091120062912-phpapp02&#038;stripped_title=massive-emailing-with-linux-postfix-and-ruby-on-rails" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=massiveemailer-091120062912-phpapp02&#038;stripped_title=massive-emailing-with-linux-postfix-and-ruby-on-rails" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
<p><a href="http://www.ivanhq.net/stuff/massive_emailer.pdf">Here is the PDF</a> for downloading.</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2009/11/20/massive-emailer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rubyonrails.org en parking!</title>
		<link>http://ivanhq.net/2009/04/23/rubyonrailsorg-en-parking/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rubyonrailsorg-en-parking</link>
		<comments>http://ivanhq.net/2009/04/23/rubyonrailsorg-en-parking/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 16:03:38 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=254</guid>
		<description><![CDATA[DIOS!! esta es de las cosas más fuertes que he visto en internet en los últimos años&#8230; El dominio de Ruby On Rails (rubyonrails.org) está en parking!! He mirado el registro del whois, y veo que el dominio ha caducado. Desde hoy mismo (23 de Abril 2009, día de Sant Jordi) pertenece a unos registradores [...]]]></description>
			<content:encoded><![CDATA[<p>DIOS!! esta es de las cosas más fuertes que he visto en internet en los últimos años&#8230; El dominio de <b>Ruby On Rails</b> (<a href="http://rubyonrails.org">rubyonrails.org</a>) está en parking!!</p>
<p>He mirado el registro del whois, y veo que el dominio ha caducado. Desde hoy mismo (23 de Abril 2009, día de Sant Jordi) pertenece a unos registradores masivos, de estos que te secuestran el dominio y luego te piden $15.000 por el.<br />
Y desde luego la culpa no es de los bulk registers, sino del propietario anterior del dominio. Yo siempre me preocupo de renovar mis dominios antes de que caduquen.<br />
Y es que en realidad el hecho de que se lo hayan quitado significa, no sólo que no se ha preocupado de renovarlo, sino que también se le ha pasado el periodo de redención (1 o 2 semanas, ahora no estoy seguro).</p>
<p>Bueno ahora la gran pregunta es dónde encontrar la documentación de la API, algo que uso a diario, y que ahora desde <a href="http://www.gotapi.com">Gotapi</a> no está disponible.</p>
<p>Qué es lo que ha pasado??? y ahora que????</p>
<p><b>EDIT:</b> son las 20:31 y ya está funcionando again. No sé qué es lo que ha pasado, pero en 1 minuto se me ha venido el mundo encima. Se da uno cuenta de lo frágiles que somos, y lo delgada que es la cuerda sobre la que caminamos&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2009/04/23/rubyonrailsorg-en-parking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove email confirmation on restful_authentication</title>
		<link>http://ivanhq.net/2009/03/17/remove-email-confirmation-on-restful_authentication/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=remove-email-confirmation-on-restful_authentication</link>
		<comments>http://ivanhq.net/2009/03/17/remove-email-confirmation-on-restful_authentication/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 17:56:19 +0000</pubDate>
		<dc:creator>ivan</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://ivanhq.net/?p=215</guid>
		<description><![CDATA[SPANISH: Al considerar este artículo de interés común y dado que no he encontrado la explicación en ningún otro sitio, voy a redactarlo en inglés por si puede servir a alguien en un futuro. Si hay algo que no se entienda bien, no dudéis preguntármelo. I&#8217;m working on an online app about auctions. A lot [...]]]></description>
			<content:encoded><![CDATA[<p><b>SPANISH:</b> Al considerar este artículo de interés común y dado que no he encontrado la explicación en ningún otro sitio, voy a redactarlo en inglés por si puede servir a alguien en un futuro. Si hay algo que no se entienda bien, no dudéis <a href="mailto:ivan (at) ivanhq.net">preguntármelo</a>.</p>
<p>I&#8217;m working on an online app about auctions. A lot of the users coming to register don&#8217;t complete the email confirmation process, although I advise it in a red huge font at the login form. Most of the time I&#8217;m getting emils of users saying they registered but can&#8217;t login. When I look into the database, they didn&#8217;t activate their accounts.</p>
<p>Well, finally our CEO&#8217;s decided to remove the activation process. And this is when I&#8217;ve been googling for hours without luck, nobody explains the way to do it. Well no problem, it hasn&#8217;t been difficult at all. This is the way: a user is active if its activation_code in the database is Null.</p>
<ul>
<li>Edit <b>models/user.rb</b> and remove this filter
<pre>
before_create :make_activation_code
</pre>
</li>
<li>In the same <b>models/user.rb</b> file, remove the <b>activate</b> method (we&#8217;re not activating any more user)</li>
<li>In the same <b>models/user.rb</b> file, remove the <b>make_activation_code</b> method (it&#8217;s almost at the end of the file).</li>
</li>
<li>Now edit <b>controllers/users_controller.rb</b>,  remove completelly the <b>activate</b> method</li>
<li>In the same <b>controller/users_controller.rb</b> file, in the <b>create</b> mehod, set the <i>activated_at</i> time before saving the user
<pre>
@user = User.new(params[:user])
@user.activated_at = Time.now.utc  # <--- add this line
    if @user.save
    [...]
</pre>
</li>
<li>Edit <b>models/user_mailer.rb</b> and completelly remove the <b>activation</b> method</li>
<li>Remove the file <b>views/user_mailer/activation.html.rb</b></li>
<li>Edit the file <b>views/user_mailer/signup_notification.html.erb</b> and set the message as you like (variables are coming from <b>models/user_mailer.rb</b>)</li>
<li>Restart your app and test</li>
</ul>
<p>I'm sure there are better ways, and I'm not the best coder in the world, but this way works for me. Maybe it will help someone one day...</p>
]]></content:encoded>
			<wfw:commentRss>http://ivanhq.net/2009/03/17/remove-email-confirmation-on-restful_authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

