<?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>P(failure &#124; big_shot_present) = .9 &#187; ruby</title>
	<atom:link href="http://blog.e-thang.net/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.e-thang.net</link>
	<description>If even 1 person reads this, I will consider that a success</description>
	<lastBuildDate>Wed, 19 Oct 2011 14:52:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Big gotcha with Carrierwave and custom versions/processors</title>
		<link>http://blog.e-thang.net/2011/10/17/big-gotcha-with-carrierwave-and-custom-versionsprocessors/</link>
		<comments>http://blog.e-thang.net/2011/10/17/big-gotcha-with-carrierwave-and-custom-versionsprocessors/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 14:52:37 +0000</pubDate>
		<dc:creator>e-thang</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[carrierwave custom processing]]></category>
		<category><![CDATA[carrierwave custom version]]></category>

		<guid isPermaLink="false">http://blog.e-thang.net/?p=158</guid>
		<description><![CDATA[Short version: Make bloody sure your versions don&#8217;t have the same name as your methods you call with process: Long version: I forget the exact sequence that brought me to this problem, but I was doing baby steps through setting up some custom versions and processes with Carrierwave.  I had set up the following (roughly): [...]]]></description>
			<content:encoded><![CDATA[<p>Short version: Make bloody sure your versions don&#8217;t have the same name as your methods you call with process:</p>
<p>Long version:</p>
<p>I forget the exact sequence that brought me to this problem, but I was doing baby steps through setting up some custom versions and processes with Carrierwave.  I had set up the following (roughly):</p>
<blockquote><p>
class PreviewUploader &lt; CarrierWave::Uploader::Base</p>
<p>version :detail_bob do</p>
<p>process :detail_bob =&gt; &#8216;bob&#8217;<br />
end<br />
end</p></blockquote>
<p>I had an included file in lib that defined &#8220;detail_bob.&#8221;  I was getting the error:</p>
<blockquote><p>ArgumentError: wrong number of arguments (1 for 0)</p></blockquote>
<p>The best part was that I&#8217;d get THAT error even if I removed the include for my library file that defined detail_bob!  I would have expected something more along the lines of &#8220;undefined method,&#8221; or something like that.</p>
<p>Anyway, it turned out that giving the version and the process call the same name was causing the problem.  I suspect that the process call was invoking method &#8220;detail_bob&#8221; that was defined by the version call.  Since the lib file was included before the call to version (naturally), the version overrode the lib file version.</p>
<p>Hopefully this can save you some grief.</p>
<blockquote><p>&nbsp;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.e-thang.net/2011/10/17/big-gotcha-with-carrierwave-and-custom-versionsprocessors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RVM woes on Ubuntu 11.04</title>
		<link>http://blog.e-thang.net/2011/05/19/rvm-woes-on-ubuntu-11-04/</link>
		<comments>http://blog.e-thang.net/2011/05/19/rvm-woes-on-ubuntu-11-04/#comments</comments>
		<pubDate>Thu, 19 May 2011 11:17:12 +0000</pubDate>
		<dc:creator>e-thang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[installation problems]]></category>
		<category><![CDATA[rvm]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.e-thang.net/?p=135</guid>
		<description><![CDATA[Having had an epiphany the other day, I needed this morning to start work on a new prototype.  This post isn&#8217;t about that prototype. It IS about the new setup I was using to do that prototype.  I figured this was a good chance to try out RVM in a Rails project, as well as [...]]]></description>
			<content:encoded><![CDATA[<p>Having had an epiphany the other day, I needed this morning to start work on a new prototype.  This post isn&#8217;t about that prototype.</p>
<p>It IS about the new setup I was using to do that prototype.  I figured this was a good chance to try out <a href="https://rvm.beginrescueend.com/">RVM</a> in a <a href="http://rubyonrails.org/">Rails</a> project, as well as try out <a href="http://www.ubuntu.com/download/ubuntu/download">Ubuntu 11.04</a>, as well as install the OS in <a href="http://en.wikipedia.org/wiki/France">French</a>.  So, with the new VM up and running, I follow RVM&#8217;s installation instructions, anticipation building with each scrolling character.  And then&#8230; BAM!</p>
<blockquote><p>ethan@ubuntu11:~/rvmsource$ bash &lt; &lt;(curl -s https://rvm.beginrescueend.com/install/rvm)<br />
Cloning into rvm&#8230;<br />
remote: Counting objects: 4765, done.<br />
remote: Compressing objects: 100% (2433/2433), done.<br />
remote: Total 4765 (delta 3086), reused 3183 (delta 1672)<br />
Receiving objects: 100% (4765/4765), 1.57 MiB | 322 KiB/s, done.<br />
Resolving deltas: 100% (3086/3086), done.<br />
WARNING:<br />
Could not source &#8216;/home/ethan/.rvm/scripts/base&#8217; as file does not exist.<br />
RVM will likely not work as expected.<br />
WARNING:<br />
Could not source &#8216;/home/ethan/.rvm/scripts/version&#8217; as file does not exist.<br />
RVM will likely not work as expected.<br />
WARNING:<br />
Could not source &#8216;/home/ethan/.rvm/scripts/selector&#8217; as file does not exist.<br />
RVM will likely not work as expected.<br />
WARNING:<br />
Could not source &#8216;/home/ethan/.rvm/scripts/cd&#8217; as file does not exist.<br />
RVM will likely not work as expected.<br />
WARNING:<br />
Could not source &#8216;/home/ethan/.rvm/scripts/cli&#8217; as file does not exist.<br />
RVM will likely not work as expected.<br />
WARNING:<br />
Could not source &#8216;/home/ethan/.rvm/scripts/override_gem&#8217; as file does not exist.<br />
RVM will likely not work as expected.<br />
cat: /home/ethan/.rvm/VERSION: Aucun fichier ou dossier de ce type</p></blockquote>
<p>A few Google searches turned up a few people having a similar problem but no solutions.  But whould&#8217;ve thunk it that installing the OS in French would actually have some practical value?  Google must&#8217;ve seen that and then dumped me on to <a href="http://forum.ubuntu-fr.org/viewtopic.php?pid=3843024">this forum</a>, wherein one of the posters linked to <a href="http://blog.escarworld.com/post/2010/09/02/Installer-rubyonrails-3.0.0-et-ruby-1.9.2-avec-rvm-sur-ubuntu-10.04">this post</a>, which basically says to just follow the directions that RVM spit out as part of the big error message.  Who&#8217;d've thunk THAT?  I sure didn&#8217;t.  I just focused on the error message itself in my searches.</p>
<blockquote><p>WARNING:  you have a &#8216;return&#8217; statement in your ~/.bashrc<br />
This could cause some features of RVM to not work.</p>
<p>This means that if you see something like:</p>
<p>&#8216;[ -z "$PS1" ] &amp;&amp; return&#8217;</p>
<p>then you change this line to:</p>
<p>if [[ -n "$PS1" ]] ; then</p>
<p># &#8230; original content that was below the &#8216;&amp;&amp; return&#8217; line &#8230;</p>
<p>fi # &lt;= be sure to close the if at the end of the .bashrc.</p>
<p># This is a good place to source rvm v v v<br />
[[ -s "/home/ethan/.rvm/scripts/rvm" ]] &amp;&amp; source &#8220;/home/ethan/.rvm/scripts/rvm&#8221;  # This loads RVM into a shell session.</p></blockquote>
<p>It looks like RVM tries to run outside of a standard shell session, and the way .bashrc is configured by default on Ubuntu 11.04 prevents that sort of thing.  When you&#8217;re done with your edits your .bashrc should look something like this:</p>
<blockquote><p># &#8216;[ -z "$PS1" ] &amp;&amp; return&#8217; &lt;&#8212;&#8211; delete this line.  It isn&#8217;t commented out in the original</p>
<p>if [[ -n "$PS1" ]] ; then</p>
<p># the rest of your old .bashrc contents</p>
<p>fi</p>
<p>[[ -s "/home/ethan/.rvm/scripts/rvm" ]] &amp;&amp; source &#8220;/home/ethan/.rvm/scripts/rvm&#8221;  # This loads RVM into a shell session.</p></blockquote>
<p>After making that change I re-ran <a href="https://rvm.beginrescueend.com/rvm/install/">the installation instructions</a>, and PRESTO!  Or maybe I should say, Voilà!  As always, YMMV.  I really don&#8217;t think it was the double install that fixed the problem.  And be sure to replace &#8220;ethan&#8221; with whatever your actual path is.  That happens to be mine, because, well, that&#8217;s my name.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.e-thang.net/2011/05/19/rvm-woes-on-ubuntu-11-04/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Deprecation warnings in Rails</title>
		<link>http://blog.e-thang.net/2011/03/22/deprecation-warnings-in-rails/</link>
		<comments>http://blog.e-thang.net/2011/03/22/deprecation-warnings-in-rails/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 12:31:28 +0000</pubDate>
		<dc:creator>e-thang</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.e-thang.net/?p=109</guid>
		<description><![CDATA[Are you working on an ever-evolving code base? Did your project start with an initial engineering effort to fix a specific problem / explore the solution space? As requirements are more fully understood, are you increasingly annoyed with the older code to support different data formats and the like? Do you want to get developers [...]]]></description>
			<content:encoded><![CDATA[<p>Are you working on an ever-evolving code base?  Did your project start with an initial engineering effort to fix a specific problem / explore the solution space?  As requirements are more fully understood, are you increasingly annoyed with the older code to support different data formats and the like?  Do you want to get developers and others to stop using those old formats?</p>
<p>Well, you too can have access to what Rails uses to put deprecation warnings in the log file.</p>
<p><code>ActiveSupport::Deprecation.warn("Stop calling me!")</code></p>
<p>It of course takes a good team policy to require all such warnings to be removed, but I was delighted to find that this is readily available and usable for my own deprecation warnings.  It sure beats using Rails.logger, because the intent is clearer, and such warnings will get shut off when all deprecation warnings are turned off anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.e-thang.net/2011/03/22/deprecation-warnings-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When having trouble installing the mysql gem on OSX</title>
		<link>http://blog.e-thang.net/2010/04/21/when-having-trouble-installing-the-mysql-gem-on-osx/</link>
		<comments>http://blog.e-thang.net/2010/04/21/when-having-trouble-installing-the-mysql-gem-on-osx/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 18:33:09 +0000</pubDate>
		<dc:creator>e-thang</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[mysql gem]]></category>

		<guid isPermaLink="false">http://blog.e-thang.net/?p=89</guid>
		<description><![CDATA[And you get an error like: *** extconf.rb failed *** Go read: http://blog.bmn.name/2008/02/rails-gem-install-mysql-throws-error-extconfrb-failed]]></description>
			<content:encoded><![CDATA[<p>And you get an error like:</p>
<p>*** extconf.rb failed ***</p>
<p>Go read:</p>
<p><a href="http://blog.bmn.name/2008/02/rails-gem-install-mysql-throws-error-extconfrb-failed">http://blog.bmn.name/2008/02/rails-gem-install-mysql-throws-error-extconfrb-failed</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.e-thang.net/2010/04/21/when-having-trouble-installing-the-mysql-gem-on-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paperclip/ImageMagick/RMagick error: &#8220;is not recognized by the &#8216;identify&#8217; command&#8221;</title>
		<link>http://blog.e-thang.net/2009/12/30/paperclipimagemagickrmagick-error-is-not-recognized-by-the-identify-command/</link>
		<comments>http://blog.e-thang.net/2009/12/30/paperclipimagemagickrmagick-error-is-not-recognized-by-the-identify-command/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 04:19:12 +0000</pubDate>
		<dc:creator>e-thang</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[paperclip]]></category>
		<category><![CDATA[rmagick]]></category>

		<guid isPermaLink="false">http://blog.e-thang.net/?p=70</guid>
		<description><![CDATA[If you&#8217;re using the above combination, and you&#8217;re getting the above error, make sure that you&#8217;ve configured Paperclip to find ImageMagick in the right place.  Create an initializer file, RAILS_ROOT/config/intializers/paperclip.rb, and put &#8220;Paperclip.options[:image_magick_path] = &#8216;path/to/image_magic&#8217;&#8221; inside of it.  On Mac or a *nix system, type &#8220;which identify&#8221; to find the right folder. Big thanks to [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using the above combination, and you&#8217;re getting the above error, make sure that you&#8217;ve configured Paperclip to find ImageMagick in the right place.  Create an initializer file, RAILS_ROOT/config/intializers/paperclip.rb, and put &#8220;Paperclip.options[:image_magick_path] = &#8216;path/to/image_magic&#8217;&#8221; inside of it.  On Mac or a *nix system, type &#8220;which identify&#8221; to find the right folder.</p>
<p>Big thanks to avit on <a href="http://railsforum.com/viewtopic.php?pid=73000#p73000">this forum</a> for the solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.e-thang.net/2009/12/30/paperclipimagemagickrmagick-error-is-not-recognized-by-the-identify-command/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Installing Ruby gems that require building native extensions on Snow Leopard</title>
		<link>http://blog.e-thang.net/2009/12/18/installing-ruby-gems-that-require-building-native-extensions-on-snow-leopard/</link>
		<comments>http://blog.e-thang.net/2009/12/18/installing-ruby-gems-that-require-building-native-extensions-on-snow-leopard/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 19:31:47 +0000</pubDate>
		<dc:creator>e-thang</dc:creator>
				<category><![CDATA[rant]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://blog.e-thang.net/?p=60</guid>
		<description><![CDATA[I haven&#8217;t tested this on all &#8220;machines&#8221; running Snow Leopard, but on the brand new one I had to get today for work, I found that the default Ruby / Gems install doesn&#8217;t support installing gems that require building native extensions. The error message I was treated to contained the following: MacBook-Pro-de-Ethan-Garofolo:~ juanpaco$ sudo gem [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t tested this on all &#8220;machines&#8221; running Snow Leopard, but on the brand new one I had to get today for work, I found that the default Ruby / Gems install doesn&#8217;t support installing gems that require building native extensions.  The error message I was treated to contained the following:</p>
<p><code>MacBook-Pro-de-Ethan-Garofolo:~ juanpaco$ sudo gem install thin<br />
Password:<br />
Building native extensions.  This could take a while...<br />
ERROR:  Error installing thin:<br />
	ERROR: Failed to build gem native extension.<br />
<code><br />
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install thin<br />
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h</p>
<p><code><br />
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/eventmachine-0.12.10 for inspection.<br />
Results logged to /Library/Ruby/Gems/1.8/gems/eventmachine-0.12.10/ext/gem_make.out</p>
<p>The solution was hyper-intuitive.  Install XCode.  Because of course that's the first thing you think of.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.e-thang.net/2009/12/18/installing-ruby-gems-that-require-building-native-extensions-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Renaming a database in Rails</title>
		<link>http://blog.e-thang.net/2009/12/14/renaming-a-database-in-rails/</link>
		<comments>http://blog.e-thang.net/2009/12/14/renaming-a-database-in-rails/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 17:09:15 +0000</pubDate>
		<dc:creator>e-thang</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[myql]]></category>
		<category><![CDATA[rename database]]></category>

		<guid isPermaLink="false">http://blog.e-thang.net/?p=54</guid>
		<description><![CDATA[Hooray for a non-rant post! The heart of this method works outside of Rails, but there&#8217;s one particular convenience method that Rails provides.  Find some way to mimic that behavior, and the rest would apply.  Also, this is a MySQL-specific solution.  I haven&#8217;t tried it with any other DB systems. We &#8220;rename&#8221; a database by [...]]]></description>
			<content:encoded><![CDATA[<p>Hooray for a non-rant post!</p>
<p>The heart of this method works outside of Rails, but there&#8217;s one particular convenience method that Rails provides.  Find some way to mimic that behavior, and the rest would apply.  Also, this is a MySQL-specific solution.  I haven&#8217;t tried it with any other DB systems.</p>
<p>We &#8220;rename&#8221; a database by moving all of its tables into a new database.  We do so via <a title="MySQL RENAME TABLE Syntax" href="http://dev.mysql.com/doc/refman/5.0/en/rename-table.html">MySQL&#8217;s RENAME TABLE command</a>.  Basically, create an empty database with the new name.  We then use our ActiveRecord connection&#8217;s &#8220;tables&#8221; method to loop over all the tables in our database, executing a RENAME TABLE from the old to the new with each iteration.  &#8220;Tables&#8221; is the convenience method I mentioned above. Encapsulating this in a method we get:</p>
<pre>def rename_database(old_db_name, new_db_name)
    ActiveRecord::Base.connection.execute "CREATE DATABASE #{new_db_name}"
    ActiveRecord::Base.connection.tables.each do |table|
        ActiveRecord::Base.connection.execute
            "RENAME TABLE #{old_db_name}.#{table} TO #{new_db_name}.#{table}"
    end
    ActiveRecord::Base.connection.execute "DROP DATABASE #{old_db_name}"
end</pre>
<p>Error checking is left as an (important!) exercise to the reader.  Also, you may prefer to monkey patch this into ActiveRecord itself as opposed to some odd method floating around in global space.</p>
<p>This presupposes that the new database destination will be on the same server.</p>
<p>Another way to rename a database is to mysqldump the old one to a file and then reimport it to the renamed database.  The method presented in this article is advantageous if your database has a large amount of data.  Renaming a table is almost instant.  <strong>Dumping millions of rows and reimporting them is not so instant.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.e-thang.net/2009/12/14/renaming-a-database-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to tell where your gems are installed</title>
		<link>http://blog.e-thang.net/2009/09/16/how-to-tell-where-your-gems-are-installed/</link>
		<comments>http://blog.e-thang.net/2009/09/16/how-to-tell-where-your-gems-are-installed/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 17:45:49 +0000</pubDate>
		<dc:creator>e-thang</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[gems]]></category>

		<guid isPermaLink="false">http://blog.e-thang.net/?p=47</guid>
		<description><![CDATA[From http://groups.google.com/group/rubypgh/msg/0489eed858e642a0: gem environment Type the above. That is all.]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://groups.google.com/group/rubypgh/msg/0489eed858e642a0">http://groups.google.com/group/rubypgh/msg/0489eed858e642a0</a>:</p>
<p><code>gem environment</code></p>
<p>Type the above.  That is all.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.e-thang.net/2009/09/16/how-to-tell-where-your-gems-are-installed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

