<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Hack to Learn: Hack to fix "undefined method" error when running rake on a gem not yet installed</title>
    <link>http://blog.cbciweb.com/articles/2008/07/03/hack-to-fix-undefined-method-error-when-running-rake-on-a-gem-not-yet-installed</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>just do it</description>
    <item>
      <title>Hack to fix &amp;quot;undefined method&amp;quot; error when running rake on a gem not yet installed</title>
      <description>&lt;p&gt;Recently, while trying to install the ultrasphinx gem for one of our projects, I ran into this little bonus:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;(in /Users/cblackburn/Source/ruby/bols)
These gems that this application depends on are missing:
 - ultrasphinx
Run &amp;quot;rake gems:install&amp;quot; to install them.
rake aborted!
undefined method `validates_email_address' for #&amp;lt;Class:0x1f577f0&amp;gt;
/Users/cblackburn/Source/ruby/bols/rakefile:11
(See full trace by running task with --trace)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;As usual I won&amp;#8217;t bore you with why it happens other than to say the loader doesn&amp;#8217;t work properly in this instance.  To hack around it find out which models are using the &amp;#8216;undefined method&amp;#8217; and place the following inside the class definition, before using the method.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="comment"&gt;# Hack to fix &amp;quot;undefined method&amp;quot; error when running rake on a gem not yet installed&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="constant"&gt;File&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;join&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="constant"&gt;RAILS_ROOT&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;config&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;initializers&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;custom_validations&lt;/span&gt;&lt;span class="punct"&gt;')&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Comment if you need more help or if this is not clear.&lt;/p&gt;</description>
      <pubDate>Thu, 03 Jul 2008 16:15:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5623cf28-b9c2-4ba0-bba9-2ff6eff2db58</guid>
      <author>Chris Blackburn</author>
      <link>http://blog.cbciweb.com/articles/2008/07/03/hack-to-fix-undefined-method-error-when-running-rake-on-a-gem-not-yet-installed</link>
      <category>Ruby</category>
      <category>ruby</category>
      <category>rubyonrails</category>
      <category>rails</category>
      <category>hack</category>
      <category>snippet</category>
      <category>fix</category>
      <category>workaround</category>
      <category>bugfix</category>
      <category>bug</category>
      <trackback:ping>http://blog.cbciweb.com/articles/trackback/43</trackback:ping>
    </item>
  </channel>
</rss>
