<?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>petersteinberger.com &#187; RubyOnRails</title>
	<atom:link href="http://petersteinberger.com/category/coding/rubyonrails/feed/" rel="self" type="application/rss+xml" />
	<link>http://petersteinberger.com</link>
	<description>bits about life, coding and stuff</description>
	<lastBuildDate>Fri, 13 Jan 2012 16:32:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>5 quotes by the creator of PHP, Rasmus Lerdorf: I don&#8217;t like programming, and I&#8217;m not a real programmer.</title>
		<link>http://petersteinberger.com/2010/04/5-quotes-by-the-creator-of-php-rasmus-lerdorf-i-dont-like-programming-and-im-not-a-real-programmer/</link>
		<comments>http://petersteinberger.com/2010/04/5-quotes-by-the-creator-of-php-rasmus-lerdorf-i-dont-like-programming-and-im-not-a-real-programmer/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 21:49:59 +0000</pubDate>
		<dc:creator>studpete</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://petersteinberger.com/?p=823</guid>
		<description><![CDATA[I really don&#8217;t like programming. I built this tool to program less so that I could just reuse code. PHP is about as exciting as your toothbrush. You use it every day, it does the job, it is a simple tool, so what? Who would want to read about toothbrushes? I was really, really bad [...]
Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/05/25-best-programmer-comics/' rel='bookmark' title='25 Best Programmer Comics'>25 Best Programmer Comics</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<ul>
<li>I really don&#8217;t like programming. I built this tool to program less so that I could just reuse code.</li>
<li>PHP is about as exciting as your toothbrush. You use it every day, it does the job, it is a simple tool, so what? Who would want to read about toothbrushes?</li>
<li>I was really, really bad at writing parsers. I still am really bad at writing parsers. We have things like protected properties. We have abstract methods. We have all this stuff that your computer science teacher told you you should be using. I don&#8217;t care about this crap at all.</li>
<li>There are people who actually like programming. I don&#8217;t understand why they like programming.</li>
<li>I&#8217;m not a real programmer. I throw together things until it works then I move on. The real programmers will say &#8220;yeah it works but you&#8217;re leaking memory everywhere. Perhaps we should fix that.&#8221; I&#8217;ll just restart apache every 10 requests.</li>
</ul>
<p><a href="http://axonflux.com/5-quotes-by-the-creator-of-php-rasmus-lerdorf" target="_blank" class="liexternal">Reposted from Axon Flux</a> <a href="http://en.wikiquote.org/wiki/Rasmus_Lerdorf" target="_blank" class="liexternal">and Wikiqoute</a>.</p>
<p>+1 for Ruby!</p>
<p>Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/05/25-best-programmer-comics/' rel='bookmark' title='25 Best Programmer Comics'>25 Best Programmer Comics</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://petersteinberger.com/2010/04/5-quotes-by-the-creator-of-php-rasmus-lerdorf-i-dont-like-programming-and-im-not-a-real-programmer/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Compress JavaScript with YUI Compressor</title>
		<link>http://petersteinberger.com/2009/10/compress-javascript-with-yui-compressor/</link>
		<comments>http://petersteinberger.com/2009/10/compress-javascript-with-yui-compressor/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 14:18:07 +0000</pubDate>
		<dc:creator>studpete</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://petersteinberger.com/?p=461</guid>
		<description><![CDATA[JavaScript files that are served to the user should be compressed and minified, and ideally everything packed into ONE big file. You can do this with some rails plugins (not tested so far), or using the &#8220;manual&#8221; way of compressing it yourself.  (or download a compressed file I worked with YUI Compressor on compressing a [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>JavaScript files that are served to the user should be compressed and minified, and ideally everything packed into ONE big file. You can do this with some <a href="http://synthesis.sbecker.net/pages/asset_packager" target="_blank" class="liexternal">rails plugins</a> (not tested so far), or using the &#8220;manual&#8221; way of compressing it yourself.  (or download a compressed file <img src='http://petersteinberger.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I worked with <a href="http://developer.yahoo.com/yui/compressor/" target="_blank" class="liexternal">YUI Compressor</a> on compressing a fresh git clone of <a href="http://github.com/tonytomov/jqGrid/tree/jqgrid36" target="_blank" class="liexternal">jqGrid</a>.</p>
<p>From Yahoos developer page:</p>
<blockquote><p>The YUI Compressor is written in <a href="http://java.sun.com/" style="color: #0000de;" target="_blank" class="liexternal">Java</a> (requires Java &gt;= 1.4) and relies on <a href="http://www.mozilla.org/rhino/" style="color: #0000de;" target="_blank" class="liexternal">Rhino</a> to tokenize the source JavaScript file. It starts by analyzing the source JavaScript file to understand how it is structured. It then prints out the token stream, omitting as many white space characters as possible, and replacing all local symbols by a 1 (or 2, or 3) letter symbol wherever such a substitution is appropriate</p></blockquote>
<p>This is a typical call:</p>
<p><code> java -jar yuicompressor-2.4.2.jar --charset=utf-8 -o dist\jquery.jqGrid.min.js jquery.jqGrid.js<br />
</code></p>
<p>With jqGrid, you have many js files that need to be merged together. You can do this manually (sucks) or with some kind of script. For jqGrid, pbor provides an <a href="http://github.com/pbor/jqGrid/raw/master/build.xml" target="_blank" class="liexternal">ANT script</a>. Copy yuicompressor, build.xml and build.properties in jqGrid source, change build.properties to mach the yui path (mostly YUICompressor=yuicompressor-2.4.2.jar) and start it via shell&gt; ant.</p>
<p>Voila! Your minified jgGrid is waiting in the dist\ folder for you.</p>
<p><strong>Update</strong>: In the tqgrid36 branch, build.xml and build.properties are already there. So you just have to modify the .properties to match your yui path.</p>
<p><code><br />
ant<br />
</code></p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://petersteinberger.com/2009/10/compress-javascript-with-yui-compressor/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>BigOldRailsTemplate</title>
		<link>http://petersteinberger.com/2009/10/bigoldrailstemplate/</link>
		<comments>http://petersteinberger.com/2009/10/bigoldrailstemplate/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 09:42:17 +0000</pubDate>
		<dc:creator>studpete</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://petersteinberger.com/?p=458</guid>
		<description><![CDATA[Playing around with BigOldRailsTemplate. There are (in the full sense of the word) many gems that I didn&#8217;t know about. What templates do you use for rails dev? Related posts: Rails + Google App Engine !?
Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/09/rails-google-app-engine/' rel='bookmark' title='Rails + Google App Engine !?'>Rails + Google App Engine !?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Playing around with <a href="http://github.com/ffmike/BigOldRailsTemplate" target="_blank" class="liexternal">BigOldRailsTemplate</a>.<br />
There are (in the full sense of the word) many gems that I didn&#8217;t know about.</p>
<p>What templates do you use for rails dev?</p>
<p>Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/09/rails-google-app-engine/' rel='bookmark' title='Rails + Google App Engine !?'>Rails + Google App Engine !?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://petersteinberger.com/2009/10/bigoldrailstemplate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Database transfer with taps</title>
		<link>http://petersteinberger.com/2009/09/database-transfer-with-taps/</link>
		<comments>http://petersteinberger.com/2009/09/database-transfer-with-taps/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 10:10:00 +0000</pubDate>
		<dc:creator>studpete</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://petersteinberger.com/?p=369</guid>
		<description><![CDATA[Stumbled on another essential tool for rails development, taps! Let you sync your server database with the local one with a breeze! On the server: taps server mysql://root@localhost/mydb tmpuser tmppass On the client: taps pull mysql://root@localhost/mydb http://tmpuser:tmppass@slicehost-box:5000 This can be done vice-versa, much better than a mysqldump! And it works even with different databases! Related [...]
Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/05/mysql5-with-mac-os-x/' rel='bookmark' title='mysql5 with mac os x'>mysql5 with mac os x</a></li>
<li><a href='http://petersteinberger.com/2010/02/backup-server-with-rsnapshot/' rel='bookmark' title='Backup Server with rsnapshot'>Backup Server with rsnapshot</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Stumbled on another essential tool for rails development, <a href="http://adamblog.heroku.com/past/2009/2/11/taps_for_easy_database_transfers/" target="_blank" class="liexternal">taps</a>!</p>
<p>Let you sync your server database with the local one with a breeze!</p>
<p>On the server:<br />
taps server mysql://root@localhost/mydb tmpuser tmppass</p>
<p>On the client:<br />
taps pull mysql://root@localhost/mydb http://tmpuser:tmppass@slicehost-box:5000</p>
<p>This can be done vice-versa, much better than a mysqldump! And it works even with different databases!</p>
<p>Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/05/mysql5-with-mac-os-x/' rel='bookmark' title='mysql5 with mac os x'>mysql5 with mac os x</a></li>
<li><a href='http://petersteinberger.com/2010/02/backup-server-with-rsnapshot/' rel='bookmark' title='Backup Server with rsnapshot'>Backup Server with rsnapshot</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://petersteinberger.com/2009/09/database-transfer-with-taps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails + Google App Engine !?</title>
		<link>http://petersteinberger.com/2009/09/rails-google-app-engine/</link>
		<comments>http://petersteinberger.com/2009/09/rails-google-app-engine/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 19:54:32 +0000</pubDate>
		<dc:creator>studpete</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://petersteinberger.com/?p=367</guid>
		<description><![CDATA[Today I experimented with a few friends how well Rails runs on Google&#8217;s App Engine. App Engine for itself works with python and java, rails works via jruby. The conditions are great, and for small apps googles engine is free. But there are several drawbacks. BigTable, googles database does NOT WORK with ActiveRecord. I believe [...]
Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/07/freezing-your-rails-versiongems/' rel='bookmark' title='Freezing your Rails version/gems!'>Freezing your Rails version/gems!</a></li>
<li><a href='http://petersteinberger.com/2009/07/rails-has_many-and-dynamic-conditions/' rel='bookmark' title='Rails has_many and dynamic conditions'>Rails has_many and dynamic conditions</a></li>
<li><a href='http://petersteinberger.com/2009/07/demystifiying-rails-model-attributes-overriding/' rel='bookmark' title='Demystifiying Rails Model attributes overriding'>Demystifiying Rails Model attributes overriding</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today I experimented with a few friends how well Rails runs on Google&#8217;s App Engine.</p>
<p>App Engine for itself works with python and java, rails works via jruby.<br />
The conditions are great, and for small apps googles engine is free.</p>
<p>But there are several drawbacks. BigTable, googles database does NOT WORK with ActiveRecord. I believe AR is one of the core features of rails. In edge rails, there is the possibility to switch your OR mapper to Data Mapper, an alternative (maybe faster) approach to ORM, which actually has BigTable-Mappings. BUT &#8211; DM does not play nicely with JRuby, at least for our experiments it didn&#8217;t work out.</p>
<p>And you loose one of rails biggest advantages, the plugins. All those acts_as_ stuff is made for ActiveRecord and not for DM.</p>
<p>So the App Engine is no alternative, except if you want to go through great pain. Maybe this changes when Data Mapper becomes more mature, and Rails 3 is released. Meanwhile, you&#8217;re better of with other hosters.</p>
<p>Try <a href="http://heroku.com" target="_blank" class="liexternal">Heroku</a>. They let you deploy your rails app within a git push. And the&#8217;re free for starting a small app! </p>
<p>Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/07/freezing-your-rails-versiongems/' rel='bookmark' title='Freezing your Rails version/gems!'>Freezing your Rails version/gems!</a></li>
<li><a href='http://petersteinberger.com/2009/07/rails-has_many-and-dynamic-conditions/' rel='bookmark' title='Rails has_many and dynamic conditions'>Rails has_many and dynamic conditions</a></li>
<li><a href='http://petersteinberger.com/2009/07/demystifiying-rails-model-attributes-overriding/' rel='bookmark' title='Demystifiying Rails Model attributes overriding'>Demystifiying Rails Model attributes overriding</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://petersteinberger.com/2009/09/rails-google-app-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pitfalls with Ruby&#8217;s Integer-Constructor</title>
		<link>http://petersteinberger.com/2009/07/pitfalls-with-rubys-integer-constructor/</link>
		<comments>http://petersteinberger.com/2009/07/pitfalls-with-rubys-integer-constructor/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 10:03:35 +0000</pubDate>
		<dc:creator>studpete</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://petersteinberger.com/?p=334</guid>
		<description><![CDATA[Got an strange error: [CC] invalid value for Integer &#8220;09&#8243; [/CC] What did I do? (&#8230;)Integer(somestring)(&#8230;) where somestring was something between 01-99. Turns out that an leading zero tells ruby that this is octal. Hell, I don&#8217;t have any octal stuff in my web app. Solution: Do it the ruby way, use .to_i &#8211; even [...]
Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/07/demystifiying-rails-model-attributes-overriding/' rel='bookmark' title='Demystifiying Rails Model attributes overriding'>Demystifiying Rails Model attributes overriding</a></li>
<li><a href='http://petersteinberger.com/2009/04/howto-update-rake-081-084-on-debian/' rel='bookmark' title='HowTo update rake 0.8.1 -&gt; 0.8.4 on debian'>HowTo update rake 0.8.1 -> 0.8.4 on debian</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Got an strange error:</p>
<p>[CC]<br />
 invalid value for Integer &#8220;09&#8243;<br />
[/CC]</p>
<p>What did I do? (&#8230;)Integer(somestring)(&#8230;) where somestring was something between 01-99.<br />
Turns out that an leading zero tells ruby that this is octal. Hell, I don&#8217;t have any octal stuff in my web app.</p>
<p>Solution: <strong>Do it the ruby way, use .to_i</strong>  &#8211; even cleaner, and no octal nonsense <img src='http://petersteinberger.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>(Why I posted this? Because I never got that error, only after hitting production mode, someone committed a 09. Pretty everything else is parseable, 00-07 is valid octal)</p>
<p><a href="http://www.ruby-forum.com/topic/62141" target="_blank" class="liexternal">Here is the source.</a></p>
<p>Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/07/demystifiying-rails-model-attributes-overriding/' rel='bookmark' title='Demystifiying Rails Model attributes overriding'>Demystifiying Rails Model attributes overriding</a></li>
<li><a href='http://petersteinberger.com/2009/04/howto-update-rake-081-084-on-debian/' rel='bookmark' title='HowTo update rake 0.8.1 -&gt; 0.8.4 on debian'>HowTo update rake 0.8.1 -> 0.8.4 on debian</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://petersteinberger.com/2009/07/pitfalls-with-rubys-integer-constructor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Demystifiying Rails Model attributes overriding</title>
		<link>http://petersteinberger.com/2009/07/demystifiying-rails-model-attributes-overriding/</link>
		<comments>http://petersteinberger.com/2009/07/demystifiying-rails-model-attributes-overriding/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 14:43:17 +0000</pubDate>
		<dc:creator>studpete</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://petersteinberger.com/?p=321</guid>
		<description><![CDATA[In the java world, you have setter and getter in your model which are called ALWAYS. Change some behaviour in the setter/getter and you are done. Things are somewhat more complicated if we look at rails and activerecord. Imagine you have a model that should parse both minutes and a formatted hour/minute string as data: [...]
Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/07/rails-has_many-and-dynamic-conditions/' rel='bookmark' title='Rails has_many and dynamic conditions'>Rails has_many and dynamic conditions</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In the java world, you have setter and getter in your model which are called ALWAYS. Change some behaviour in the setter/getter and you are done. Things are somewhat more complicated if we look at rails and activerecord.</p>
<p>Imagine you have a model that should parse both minutes and a formatted hour/minute string as data:<br />
[cc lang="ruby"]<br />
testcase.estimated_time = &#8220;90&#8243;<br />
testcase.estimated_time = &#8220;01:30&#8243;<br />
[/cc]<br />
As the data is saved as integer in minutes, some conversion has to be done to parse the second string. To get this right, it should be done in the model itself (as we may have various places in our web app where it can be edited)</p>
<p>My first try was to simply override the setter and getter in the model:</p>
<p>[cc lang="ruby"]<br />
# THIS DOES NOT WORK!</p>
<p>def estimated_time<br />
  self['estimated_time']<br />
end</p>
<p>def estimated_time=(_estimated_time)<br />
  self['estimated_time'] = _estimated_time<br />
end<br />
[/cc]</p>
<p>Well, u can assume that this doesn&#8217;t work. Why? The setter is not always called in rails &#8211; only if you directly adress estimated time, but NOT if you update a bunch of attributes (which is the normal way on a post update)</p>
<h2>Solution</h2>
<p>ActiveRecord defines the estimated_time= method on the testcase class itself.<br />
There is a technique called <a href="http://weblog.rubyonrails.org/2006/4/26/new-in-rails-module-alias_method_chain" target="_blank" class="liexternal">&#8220;methode chaining&#8221;</a>, but this only works for associations.</p>
<p>The best way to go is by using a <strong><a href="http://railscasts.com/episodes/32-time-in-text-field" target="_blank" class="liexternal">virtual property</a></strong>.</p>
<p>[cc lang="ruby"]<br />
  def estimated_time_string<br />
    helper.format_time self.estimated_time, &#8220;&#8221;<br />
  end</p>
<p>  def estimated_time_string=(_estimated_time)<br />
    self.estimated_time = convert_time(_estimated_time)<br />
  end<br />
[/cc]</p>
<p>Change your forms to use estimated_time_string instead of estimated_time.</p>
<p>Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/07/rails-has_many-and-dynamic-conditions/' rel='bookmark' title='Rails has_many and dynamic conditions'>Rails has_many and dynamic conditions</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://petersteinberger.com/2009/07/demystifiying-rails-model-attributes-overriding/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Add a version timestamp with capistrano</title>
		<link>http://petersteinberger.com/2009/07/add-a-version-timestamp-with-capistrano/</link>
		<comments>http://petersteinberger.com/2009/07/add-a-version-timestamp-with-capistrano/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 13:21:14 +0000</pubDate>
		<dc:creator>studpete</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://petersteinberger.com/?p=301</guid>
		<description><![CDATA[If you want to show _when_ the app has been deployed with capistrano, this snipped might come in handy: ############################################################# # Custom Tasks ############################################################# set :version_file, "#{tcdb_path}/app/views/layouts/_version.html.erb" namespace :my_tasks do desc "Sets the timestamp in version_file" task :set_version_info do run "rm #{version_file}" run "echo '#{Time.now}' &#62;&#62; #{version_file}" end end after 'deploy:symlink', 'my_tasks:set_version_info' One more thing&#8230; [...]
Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/07/capistrano-deploying-2-0/' rel='bookmark' title='Capistrano &#8211; Deploying 2.0'>Capistrano &#8211; Deploying 2.0</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you want to show _when_ the app has been deployed with capistrano, this snipped might come in handy:</p>
<p><code lang="ruby"><br />
#############################################################<br />
#	Custom Tasks<br />
#############################################################</p>
<p>set :version_file, "#{tcdb_path}/app/views/layouts/_version.html.erb"</p>
<p>namespace :my_tasks do<br />
desc "Sets the timestamp in version_file"<br />
task :set_version_info do<br />
run "rm #{version_file}"<br />
run "echo '#{Time.now}' &gt;&gt; #{version_file}"<br />
end<br />
end</p>
<p>after 'deploy:symlink', 'my_tasks:set_version_info'<br />
</code></p>
<p>One more thing&#8230; add this file to your layout (the footer is a good place for it)<br />
<code lang="ruby"><br />
< %= render :partial => '/layouts/version' %><br />
</code></p>
<p>Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/07/capistrano-deploying-2-0/' rel='bookmark' title='Capistrano &#8211; Deploying 2.0'>Capistrano &#8211; Deploying 2.0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://petersteinberger.com/2009/07/add-a-version-timestamp-with-capistrano/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Capistrano &#8211; Deploying 2.0</title>
		<link>http://petersteinberger.com/2009/07/capistrano-deploying-2-0/</link>
		<comments>http://petersteinberger.com/2009/07/capistrano-deploying-2-0/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 09:59:54 +0000</pubDate>
		<dc:creator>studpete</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://petersteinberger.com/?p=278</guid>
		<description><![CDATA[&#8230;because ssh&#8217;in and updating all this code manually is so 2006. Enter Capistrano! It&#8217;s for web what make is for c. It&#8217;s simple, widely used and even those php kids begin likein&#8217; it! A tool which make subsequent deployments to your webserver much easier. Installation Capostrano runs on your machine. You don&#8217;t need it on [...]
Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/07/add-a-version-timestamp-with-capistrano/' rel='bookmark' title='Add a version timestamp with capistrano'>Add a version timestamp with capistrano</a></li>
<li><a href='http://petersteinberger.com/2009/04/howto-update-rake-081-084-on-debian/' rel='bookmark' title='HowTo update rake 0.8.1 -&gt; 0.8.4 on debian'>HowTo update rake 0.8.1 -> 0.8.4 on debian</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>&#8230;because ssh&#8217;in and updating all this code manually is so 2006.</p>
<p>Enter Capistrano! It&#8217;s for web what make is for c. It&#8217;s simple, widely used and even those php kids begin likein&#8217; it!</p>
<p>A tool which make subsequent deployments to your webserver <em>much</em> easier.</p>
<h2>Installation</h2>
<p><strong>Capostrano runs on your machine</strong>. You don&#8217;t need it on your server to work!</p>
<p>[CC]</p>
<p>gem install capistrano</p>
<p>[/CC]</p>
<h2>&#8216;Capistranize&#8217; your application</h2>
<p>[CC]</p>
<p>capify .</p>
<p>[/CC]</p>
<p>Then setup the <em>config/deploy.rb </em>file. There are many guides on the net.</p>
<h2>Deploy your app</h2>
<p><code lang="ruby"><br />
cap deploy:setup # creates directories on the server<br />
cap deploy:cold # copies code + db migration<br />
cap deploy # update code (normal call)<br />
</code></p>
<h2>Capistrano + local git repo</h2>
<p>deploy.rb:</p>
<p><code lang="ruby"><br />
set :repository, "file:///file/localrepo.git"<br />
set :scm, :git<br />
set :branch, "master"<br />
set :deploy_via, :copy<br />
</code></p>
<p>The &#8220;copy&#8221; deployment strategy is the only working one, as your server does not has direct access to your repo. <em>If</em> you have a possibility to remote-upload the repo, do so, and choose the remote_cache strategy, which is <em>much</em> faster.</p>
<h2>My config</h2>
<p><code lang="ruby"><br />
#############################################################<br />
#	Application<br />
#############################################################<br />
set :application, "app"<br />
set :deploy_to, "/var/www/#{application}_src"</p>
<p>#############################################################<br />
#	Settings<br />
#############################################################</p>
<p># we don't have sudo rights<br />
set :use_sudo, false</p>
<p># set to production environment<br />
set :rails_env, 'production'</p>
<p>#############################################################<br />
#	Servers<br />
#############################################################</p>
<p>set :user, "user"<br />
set :domain, "server"<br />
role :app, domain<br />
role :web, domain<br />
role :db, domain, :primary => true</p>
<p>#############################################################<br />
#	Git<br />
#############################################################</p>
<p># we are using a local copy of the git repository<br />
set :repository, "file:///..........git"<br />
set :scm, :git<br />
set :branch, "master"<br />
set :deploy_via, :copy</p>
<p>#############################################################<br />
#	Override Tasks<br />
#############################################################</p>
<p>namespace :deploy do<br />
  task :finalize_update, :except => { :no_release => true } do<br />
    logger.info 'do nothing - overridden finalize_update'<br />
  end</p>
<p>  desc "Restarting mod_rails with restart.txt"<br />
  task :restart, :roles => :app, :except => { :no_release => true } do<br />
    run "touch #{current_path}/tmp/restart.txt"<br />
  end</p>
<p>  [:start, :stop].each do |t|<br />
    desc "#{t} task is a no-op with mod_rails"<br />
    task t, :roles => :app do<br />
    end<br />
  end<br />
end<br />
</code></p>
<h2>Links</h2>
<p><a href="http://capitate.rubyforge.org/recipes/deploy.html" target="_blank" class="liexternal">http://capitate.rubyforge.org/recipes/deploy.html</a></p>
<p><a href="http://www.softiesonrails.com/2007/4/5/the-absolute-moron-s-guide-to-capistrano" target="_blank" class="liexternal">http://www.softiesonrails.com/2007/4/5/the-absolute-moron-s-guide-to-capistrano</a></p>
<p><a href="http://github.com/guides/deploying-with-capistrano" target="_blank" class="liexternal">http://github.com/guides/deploying-with-capistrano</a></p>
<p><a href="http://www.peepcode.com/products/capistrano-concepts" target="_blank" class="liexternal">The Capistrano Peepcode Screencast</a></p>
<p><a href="http://jimneath.org/2008/05/10/using-capistrano-with-passenger-mod_rails/" target="_blank" class="liexternal">http://jimneath.org/2008/05/10/using-capistrano-with-passenger-mod_rails/</a></p>
<p>Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/07/add-a-version-timestamp-with-capistrano/' rel='bookmark' title='Add a version timestamp with capistrano'>Add a version timestamp with capistrano</a></li>
<li><a href='http://petersteinberger.com/2009/04/howto-update-rake-081-084-on-debian/' rel='bookmark' title='HowTo update rake 0.8.1 -&gt; 0.8.4 on debian'>HowTo update rake 0.8.1 -> 0.8.4 on debian</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://petersteinberger.com/2009/07/capistrano-deploying-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freezing your Rails version/gems!</title>
		<link>http://petersteinberger.com/2009/07/freezing-your-rails-versiongems/</link>
		<comments>http://petersteinberger.com/2009/07/freezing-your-rails-versiongems/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 08:32:12 +0000</pubDate>
		<dc:creator>studpete</dc:creator>
				<category><![CDATA[RubyOnRails]]></category>

		<guid isPermaLink="false">http://petersteinberger.com/?p=264</guid>
		<description><![CDATA[Ever wondered what &#8220;freeze your gems&#8221; is all about? Most rails app depend heavily on gems (rails itself is a gem!) and we somehow need to make sure that everything works together. And you really should care about this. Update all your gems [CC] sudo gem update [/CC] New gem updates may make backward incompatible [...]
Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/04/howto-update-rake-081-084-on-debian/' rel='bookmark' title='HowTo update rake 0.8.1 -&gt; 0.8.4 on debian'>HowTo update rake 0.8.1 -> 0.8.4 on debian</a></li>
<li><a href='http://petersteinberger.com/2009/09/rails-google-app-engine/' rel='bookmark' title='Rails + Google App Engine !?'>Rails + Google App Engine !?</a></li>
<li><a href='http://petersteinberger.com/2009/07/rails-has_many-and-dynamic-conditions/' rel='bookmark' title='Rails has_many and dynamic conditions'>Rails has_many and dynamic conditions</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Ever wondered what &#8220;freeze your gems&#8221; is all about?</p>
<p>Most rails app depend heavily on gems (rails itself is a gem!) and we somehow need to make sure that everything works together. And <a href="http://www.google.at/search?q=rails+gem+update+breaks+my+app" target="_blank" class="liexternal">you really should care</a> about this. </p>
<h2>Update all your gems</h2>
<p>[CC]<br />
sudo gem update<br />
[/CC]</p>
<p>New gem updates may make<strong> backward incompatible changes</strong> that breaks the code. So <strong>freezing a gem puts it into the vendor folder of the application and will not updated on its own</strong>. Rails first looks into /vendor/rails before searching everywhere else for your gems.</p>
<h2>Freeze your rails app</h2>
<p>Happy us &#8211; there&#8217;s a rake task that does all the hard work!</p>
<p>[CC]</p>
<p>rake rails:freeze:gems</p>
<p>[/CC]</p>
<p>Freezing now <span style="text-decoration: line-through;">copies</span> unpacks rails into this special folder.</p>
<p>There&#8217;s also a &#8220;rake rails:unfreeze&#8221; &#8211; command, but if you simply wanna freeze your updated rails gems, run the freeze-command again.</p>
<h2>Manage your dependencies</h2>
<p>To freeze your gems, you need to tell rails what you need. Therefore use the gem dependency feature of Rails 2.1+. Edit <em>config/environment.rb</em></p>
<p>If you don&#8217;t know what you require, read the full list via <em>gem list</em>.</p>
<p>[CC]<br />
Rails::Initializer.run do |config|<br />
&#8230;<br />
# Require the latest version of haml<br />
config.gem &#8220;haml&#8221;<br />
config.gem &#8220;thoughtbot-factory_girl&#8221;,<br />
:lib    =&gt; &#8220;factory_girl&#8221;,<br />
:source =&gt; &#8220;http://gems.github.com&#8221;<br />
&#8230;<br />
end<br />
[/CC]</p>
<p>You can require <a href="http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies" target="_blank" class="liexternal">a specific version or the latest</a> (omitting the :version parameter); custom sources are also possible via :source =&gt; (e.g. the gems.github.com stuff)</p>
<p>Now tell rake that you want to install those gems (they should be installed anyway)</p>
<p>[CC]<br />
rake gems:install<br />
[/CC]</p>
<h2 style="font-size: 1.5em;">Freeze your gems</h2>
<p>Next, we wanna freeze the gems too. The are copied into /vender/gems</p>
<p>[CC]<br />
rake gems:build<br />
rake gems:unpack:dependencies<br />
[/CC]</p>
<p>The build command makes the native extensions.</p>
<h2 style="font-size: 1.5em;">Get the list of your gems</h2>
<p>[CC]</p>
<p>rake gems</p>
<p>[/CC]</p>
<p>The &#8216;F&#8217; shows your freezed gems.</p>
<h2>Note</h2>
<p>There are <strong>some gotchas</strong> however: Gems with native extensions(libxml&#8230;) can&#8217;t be frozen, as the OS code needs to live in the external OS.</p>
<h2>Links</h2>
<p><a href="http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies" target="_blank" class="liexternal">http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies</a></p>
<p><a href="http://stackoverflow.com/questions/799416/whats-the-point-of-freezing-your-rails-version-gems" target="_blank" class="liexternal">http://stackoverflow.com/questions/799416/whats-the-point-of-freezing-your-rails-version-gems</a></p>
<p><a href="http://www.softiesonrails.com/2008/1/3/freezing-your-rails-application" target="_blank" class="liexternal">http://www.softiesonrails.com/2008/1/3/freezing-your-rails-application</a></p>
<p>Related posts:<ol>
<li><a href='http://petersteinberger.com/2009/04/howto-update-rake-081-084-on-debian/' rel='bookmark' title='HowTo update rake 0.8.1 -&gt; 0.8.4 on debian'>HowTo update rake 0.8.1 -> 0.8.4 on debian</a></li>
<li><a href='http://petersteinberger.com/2009/09/rails-google-app-engine/' rel='bookmark' title='Rails + Google App Engine !?'>Rails + Google App Engine !?</a></li>
<li><a href='http://petersteinberger.com/2009/07/rails-has_many-and-dynamic-conditions/' rel='bookmark' title='Rails has_many and dynamic conditions'>Rails has_many and dynamic conditions</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://petersteinberger.com/2009/07/freezing-your-rails-versiongems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

