<?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>Tatva-Artha &#187; rails</title>
	<atom:link href="http://www.tatvartha.com/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tatvartha.com</link>
	<description>meaning of &#34;it&#34;</description>
	<lastBuildDate>Sat, 22 Oct 2011 22:00:16 +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>Upgrading to ruby 1.9: rbx-require-relative requires Ruby version ~&gt; 1.8.7</title>
		<link>http://www.tatvartha.com/2011/08/upgrading-to-ruby-1-9-rbx-require-relative-requires-ruby-version-1-8-7/</link>
		<comments>http://www.tatvartha.com/2011/08/upgrading-to-ruby-1-9-rbx-require-relative-requires-ruby-version-1-8-7/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 18:55:49 +0000</pubDate>
		<dc:creator>Sharad</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[gemfile]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tatvartha.com/?p=493</guid>
		<description><![CDATA[If you are upgrading from ruby 1.8 or Ruby Enterprise 1.8.7 to ruby 1.9.2, you may encounter this error. Installing rbx-require-relative (0.0.5) Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/ bundler/issues so that we can fix it. Thanks!/Users/sjain/.rvm/rubies/ruby-1.9.2-p290/ lib/ruby/site_ruby/1.9.1/rubygems/ installer.rb:364:in `ensure_required_ruby_version_met': rbx-require-relative requires Ruby version ~> [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>If you are upgrading from ruby 1.8 or Ruby Enterprise 1.8.7 to ruby 1.9.2, you may encounter this error.</p>
<pre land="bash">
Installing rbx-require-relative (0.0.5) Unfortunately, a fatal error has occurred.
Please report this error to the Bundler issue tracker at https://github.com/carlhuda/
bundler/issues so that we can fix it. Thanks!/Users/sjain/.rvm/rubies/ruby-1.9.2-p290/
lib/ruby/site_ruby/1.9.1/rubygems/ installer.rb:364:in `ensure_required_ruby_version_met':
rbx-require-relative requires Ruby version ~> 1.8.7. (Gem::InstallError)
</pre>
<p>This most likely happens because you are declaring a dependency on ruby-debug gem in your Gemfile.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">group <span style="color:#ff3333; font-weight:bold;">:development</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  gem <span style="color:#996600;">'ruby-debug'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>With ruby 1.9, you need to update this with new gem name ruby-debug19.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">group <span style="color:#ff3333; font-weight:bold;">:development</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  gem <span style="color:#996600;">'ruby-debug19'</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>This will eliminate the dependency on rbx-require-relative and fix the issue.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tatvartha.com/2011/08/upgrading-to-ruby-1-9-rbx-require-relative-requires-ruby-version-1-8-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploy at will!</title>
		<link>http://www.tatvartha.com/2011/04/deploy-at-will/</link>
		<comments>http://www.tatvartha.com/2011/04/deploy-at-will/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 02:03:08 +0000</pubDate>
		<dc:creator>Sharad</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tatvartha.com/?p=474</guid>
		<description><![CDATA[Shamelessly copying one point from a github blog. It is that good. Deploy at Will! At the first RailsConf I had the pleasure of hearing Martin Fowler deliver an amazing keynote. He made some apt metaphors regarding agile development that I will now paraphrase and mangle. Imagine you’re tasked with building a computer controlled gun [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Shamelessly copying one point from a <a href="http://tom.preston-werner.com/2011/03/29/ten-lessons-from-githubs-first-year.html">github blog</a>. It is that good.</p>
<h3>Deploy at Will!</h3>
<p>At the first RailsConf I had the pleasure of hearing Martin Fowler deliver an amazing keynote. He made some apt metaphors regarding agile development that I will now paraphrase and mangle.</p>
<p>Imagine you’re tasked with building a computer controlled gun that can accurately hit a target about 50 meters distant. That is the only requirement. One way to do this is to build a complex machine that measures every possible variable (wind, elevation, temperature, etc.) before the shot and then takes aim and shoots. Another approach is to build a simple machine that fires rapidly and can detect where each shot hits. It then uses this information to adjust the aim of the next shot, quickly homing in on the target a little at a time.</p>
<p>The difference between these two approaches is to realize that bullets are cheap. By the time the former group has perfected their wind detection instrument, you’ll have finished your simple weapon and already hit the target.</p>
<p>In the world of web development, the target is your ideal offering, the bullets are your site deploys, and your customers provide the feedback mechanism. The first year of a web offering is a magical one. Your customers are most likely early adopters and love to see new features roll out every few weeks. If this results in a little bit of downtime, they’ll easily forgive you, as long as those features are sweet. In the early days of GitHub, we’d deploy up to ten times in one afternoon, always inching closer to that target.</p>
<p>Make good use of that first year, because once the big important customers start rolling in, you have to be a lot more careful about hitting one of them with a stray bullet. Later in the game, downtime and botched deploys are money lost and you have to rely more on building instruments to predict where you should aim.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tatvartha.com/2011/04/deploy-at-will/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mocha unexpected invocation errors</title>
		<link>http://www.tatvartha.com/2011/03/mocha-unexpected-invocation-errors/</link>
		<comments>http://www.tatvartha.com/2011/03/mocha-unexpected-invocation-errors/#comments</comments>
		<pubDate>Sat, 12 Mar 2011 04:38:39 +0000</pubDate>
		<dc:creator>Sharad</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[mocha]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tatvartha.com/?p=470</guid>
		<description><![CDATA[If you find that your tests pass when run alone but fail with &#8220;unexpected invocation&#8221; inside &#8220;rake test&#8221;, you are most likely seeing behavior that is caused by mocha load order. This is a documented gotcha with mocha. And also discussed here. It happens when mocha gem is listed as library dependency inside rails app. [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>If you find that your tests pass when run alone but fail with &#8220;unexpected invocation&#8221; inside &#8220;rake test&#8221;, you are most likely seeing behavior that is caused by mocha load order.</p>
<p>This is a <a href="http://mocha.rubyforge.org/">documented</a> gotcha with mocha. And also discussed <a href="http://blog.agoragames.com/2010/09/10/rails-3-mocha-load-order-gotcha/">here</a>.</p>
<p>It happens when mocha gem is listed as library dependency inside rails app. The library gets loaded too soon. The fix is to load mocha after rails has booted up.</p>
<p>For rails < 3.0.0, this means removing -- config.gem 'mocha' -- entry from config/environment.rb and adding -- require 'mocha' -- at the bottom of test/test_helper.rb.</p>
<p>For rails >= 3.0.0, this means adding &#8212; :require => false &#8212; inside Gemfile entry as follows.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Gemfile</span>
group <span style="color:#ff3333; font-weight:bold;">:test</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  gem <span style="color:#996600;">'mocha'</span>, <span style="color:#ff3333; font-weight:bold;">:require</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And then adding following line at the bottom of test/test_helper.rb:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># test_helper.rb</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'mocha'</span></pre></div></div>



<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tatvartha.com/2011/03/mocha-unexpected-invocation-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveRecord::MissingAttributeError: missing attribute &#8212; a bug or a feature?</title>
		<link>http://www.tatvartha.com/2011/03/activerecordmissingattributeerror-missing-attribute-a-bug-or-a-features/</link>
		<comments>http://www.tatvartha.com/2011/03/activerecordmissingattributeerror-missing-attribute-a-bug-or-a-features/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 02:07:49 +0000</pubDate>
		<dc:creator>Sharad</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tatvartha.com/?p=464</guid>
		<description><![CDATA[Sooner or later, the need arises to assign default values to model attributes. In rails this is usually done in model&#8217;s after_initialize() with a new_record? guard. Something like: class User def after_initialize if new_record? self.country = &#34;US&#34; end end end This initializes the object with proper default so the UI form gets properly populated and [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><img src="http://4.bp.blogspot.com/_uyrxeugtbV0/RmlE-LeMZfI/AAAAAAAABII/JW3gs6QO3qw/s320/irannVVV.JPG" style="margin: 10px; height: 150px;"/></p>
<p>Sooner or later, the need arises to assign default values to model attributes. In rails this is usually done in model&#8217;s after_initialize() with a new_record? guard.</p>
<p>Something like:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> User
  <span style="color:#9966CC; font-weight:bold;">def</span> after_initialize
    <span style="color:#9966CC; font-weight:bold;">if</span> new_record?
      <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">country</span> = <span style="color:#996600;">&quot;US&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>This initializes the object with proper default so the UI form gets properly populated and the database gets proper default if user hasn&#8217;t overridden it.</p>
<p>Sometimes, you realize that you have (pre-existing?) objects in database that also need the same default if the current value is nil. In such case, you may modify your initializer like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> User
  <span style="color:#9966CC; font-weight:bold;">def</span> after_initialize
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">country</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#996600;">&quot;US&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>This works for both scenarios: User.new and User.find.</p>
<p>However, it introduces a behavior that may not be apparant immediately.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ script<span style="color: #000000; font-weight: bold;">/</span>console
ree<span style="color: #000000; font-weight: bold;">&gt;</span> User.find<span style="color: #7a0874; font-weight: bold;">&#40;</span>u.id<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  User Load <span style="color: #7a0874; font-weight: bold;">&#40;</span>0.9ms<span style="color: #7a0874; font-weight: bold;">&#41;</span>   SELECT <span style="color: #000000; font-weight: bold;">*</span> FROM <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">users</span><span style="color: #000000; font-weight: bold;">`</span> WHERE <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">users</span><span style="color: #000000; font-weight: bold;">`</span>.<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">id</span><span style="color: #000000; font-weight: bold;">`</span> = <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> 
ree<span style="color: #000000; font-weight: bold;">&gt;</span> User.exists?<span style="color: #7a0874; font-weight: bold;">&#40;</span>:<span style="color: #c20cb9; font-weight: bold;">id</span> =<span style="color: #000000; font-weight: bold;">&gt;</span> u.id<span style="color: #7a0874; font-weight: bold;">&#41;</span>
  RateSearch Load <span style="color: #7a0874; font-weight: bold;">&#40;</span>0.6ms<span style="color: #7a0874; font-weight: bold;">&#41;</span>   SELECT <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">users</span><span style="color: #000000; font-weight: bold;">`</span>.id FROM <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">users</span><span style="color: #000000; font-weight: bold;">`</span> WHERE <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">users</span><span style="color: #000000; font-weight: bold;">`</span>.<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">id</span><span style="color: #000000; font-weight: bold;">`</span> = <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> LIMIT <span style="color: #000000;">1</span>
ActiveRecord::MissingAttributeError: missing attribute: country
<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>prj<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>User.rb:<span style="color: #000000;">3</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>after_initialize<span style="color: #ff0000;">'</span></pre></div></div>

<p>A closer look reveals that ActiveRecord tries to be smart and only fetch &#8216;id&#8217; column when performing Model.exists? call.</p>
<p>Many people have tripped this and logged it as <a href="https://rails.lighthouseapp.com/projects/8994/tickets/3165-activerecordmissingattributeerror-after-update-to-rails-v-234">a bug</a>. The report has been silently ignored, and I believe, for good/performance reasons.</p>
<p>So, what do we get around it? Here&#8217;s one way.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> User
  <span style="color:#9966CC; font-weight:bold;">def</span> after_initialize
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">country</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#996600;">&quot;US&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::MissingAttributeError</span>
    <span style="color:#008000; font-style:italic;"># this should only happen on Model.exists?() call. It can be safely ignored.</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>As they say, it is not a bug, it is a feature.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tatvartha.com/2011/03/activerecordmissingattributeerror-missing-attribute-a-bug-or-a-features/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing mysql gem with bundler on Snow Leopard</title>
		<link>http://www.tatvartha.com/2010/10/installing-mysql-gem-with-bundler-on-snow-leopard/</link>
		<comments>http://www.tatvartha.com/2010/10/installing-mysql-gem-with-bundler-on-snow-leopard/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 23:34:12 +0000</pubDate>
		<dc:creator>Sharad</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://www.tatvartha.com/?p=454</guid>
		<description><![CDATA[Between 0.9.26, RC and final 1.0 release, bundler went thru some heavy changes with respect to command line options it supports. Luckily, twitter, forum and blogs kept everybody in the loop. The blogs, however, became obsolete quickly and even blog posts few months old don&#8217;t work with latest version of bundler. We came across this [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm3.static.flickr.com/2450/3593686294_600ee1b7fb_z.jpg" style="float: right; margin: 10px; height: 250px;"/></p>
<p>Between 0.9.26, RC and final 1.0 release, <a href="http://gembundler.com/">bundler</a> went thru some heavy changes with respect to command line options it supports. Luckily, <a href="http://twitter.com/indirect">twitter</a>, <a href="http://groups.google.com/group/ruby-bundler">forum</a> and <a href="http://yehudakatz.com/tags/rails-3/">blogs</a> kept everybody in the loop.</p>
<p>The blogs, however, became obsolete quickly and even blog posts few months old don&#8217;t work with latest version of bundler. We came across this issue that kept is in a loop for a while.</p>
<p>Snow Leopard changed a few things with ruby and mysql gem when it came out. Most mysql installation issues are hammered out by now and are <a href="http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard">well documented</a>.</p>
<p><span id="more-454"></span><br />
Before you jump and execute following commands, make sure that you indeed have 64 bit mysql and 64 bit ruby on your machine. (If not, these instructions may not apply to your need).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">which</span> ruby<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>xxx<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby: Mach-O <span style="color: #000000;">64</span>-bit executable x86_64
$ <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">which</span> mysql<span style="color: #000000; font-weight: bold;">`</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>mysql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysql: Mach-O <span style="color: #000000;">64</span>-bit executable x86_64</pre></div></div>

<p>Both installations should be Mach-O 64-bit x86_64 architecture.</p>
<p>In summary, installing mysql gem requires 2 things:</p>
<ul>
<li>Specifying architecture flags: ARCHFLAGS=&#8221;-arch x86_64&#8243;</li>
<li>Specify location of mysql_config to compile agains: &#8211;with-mysql-config=/usr/local/mysql/bin/mysql_config</li>
</ul>
<p>Prior to bundler, this is what you would do on snow-leopard to install mysql:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">ARCHFLAGS</span>=<span style="color: #ff0000;">&quot;-arch x86_64&quot;</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql <span style="color: #660033;">--</span> <span style="color: #660033;">--with-mysql-config</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>mysql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysql_config</pre></div></div>

<p>With bundler, there is no <a href="http://gembundler.com/man/bundle.1.html">command line option</a> that I could find that I can pass to &#8220;bundle install&#8221; command. Having been in the loop around bundler, I knew that such OS specific options don&#8217;t go in Gemfile and have to be specified in user specific files such as ~/.bundle/config file. The official website for <a href="http://gembundler.com/">gem-bundler</a> doesn&#8217;t have any mention of this (is it because we need to keep things simple for people just getting upto speed with bundler?).</p>
<p>Bundler has a feature which allow specifying build options as documented <a href="http://gembundler.com/man/bundle-config.1.html">here</a>. So, I did this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ bundle config build.mysql <span style="color: #660033;">--with-mysql-config</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>mysql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysql_config</pre></div></div>

<p>This updated my ~/.bundle/config with proper information that it will need for &#8220;bundle install&#8221; command. It make sense to keep this in ~/ folder and not my project folder since it applies only to my environment and it applies to all projects on this machine.</p>
<p>With this, doing &#8220;bundle install&#8221; still doesn&#8217;t install mysql properly. Comparing this to the pre-bundler command, it solves one issue. The ARCHFLAGS still need to be available for &#8220;bundle install&#8221;. With some leap of faith, I set an environment variable to this effect:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ARCHFLAGS</span>=<span style="color: #ff0000;">&quot;-arch x86_64&quot;</span>
<span style="color: #666666; font-style: italic;"># should this go in my .bash_profile (so that mysql installs fine always, for all projects?</span>
<span style="color: #666666; font-style: italic;"># And I don't have to remember to set this each time I do a fresh bundle install.</span></pre></div></div>

<p>And voila, &#8220;bundle install&#8221; installs mysql correctly.</p>
<p>Bundler is stable now and is making everybody&#8217;s life much much easier. It isn&#8217;t changing as fast and so this blog post won&#8217;t be obsolete too soon <img src='http://www.tatvartha.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tatvartha.com/2010/10/installing-mysql-gem-with-bundler-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rails Constants: Location matters</title>
		<link>http://www.tatvartha.com/2009/06/rails-constants-location-matters/</link>
		<comments>http://www.tatvartha.com/2009/06/rails-constants-location-matters/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 21:42:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rails constants]]></category>

		<guid isPermaLink="false">http://www.tatvartha.com/?p=163</guid>
		<description><![CDATA[Rails framework provides a standard location for defining application specific constants. All default constants go in constant/environment.rb and any environment specific overrides go in config/environments/&#60;env&#62;.rb file. Normally, any constant that is overridden in environment specific file takes precedence. However, there is a catch. If a constant is defined outside of Rails::Initializer.run block then it overrides [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Rails framework provides a standard location for defining application specific constants. All default constants go in constant/environment.rb and any environment specific overrides go in config/environments/&lt;env&gt;.rb file. Normally, any constant that is overridden in environment specific file takes precedence. However, there is a catch. If a constant is defined outside of Rails::Initializer.run block then it overrides all other definition preceding it.</p>
<p>Hence, when defining constants in default config/environment.rb file, beware:</p>
<p><code>require File.join(File.dirname(__FILE__), 'boot')</code> <br/><code>Rails::Initializer.run do |config|</code> <br/><code><span style="COLOR: #008000">A_CONSTANT = "value"</span></code> <br/><code>end</code> <br/><code><span style="COLOR: #ff0000"># Do not define environment specific constants here.</span></code></p>
<p>Enjoy!</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tatvartha.com/2009/06/rails-constants-location-matters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionMailer, GMail and TLS</title>
		<link>http://www.tatvartha.com/2009/05/actionmailer-gmail-and-tls/</link>
		<comments>http://www.tatvartha.com/2009/05/actionmailer-gmail-and-tls/#comments</comments>
		<pubDate>Mon, 04 May 2009 21:23:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tatvartha.com/?p=112</guid>
		<description><![CDATA[Prior to rails 2.3.2, if you needed to use GMail as your SMTP carrier (sending out emails from your app), you had to use one of the following plugins to modify the ActionMailer::Base class to support TLS for ActiveRecord. tlsmail ambethia-smtp-tls openrain-action_mailer_tls simplificator-tls-support In rails 2.3.2, this is supported natively, provided you had proper configuration [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Prior to rails 2.3.2, if you needed to use GMail as your SMTP carrier (sending out emails from your app), you had to use one of the following plugins to modify the ActionMailer::Base class to support TLS for ActiveRecord.</p>
<ul>
<li>tlsmail</li>
<li>ambethia-smtp-tls</li>
<li>openrain-action_mailer_tls</li>
<li>simplificator-tls-support</li>
</ul>
<p>In rails 2.3.2, this is supported natively, provided you had proper configuration specified:</p>
<p><code>config.action_mailer.raise_delivery_errors = true<br />
config.action_mailer.delivery_method = :smtp<br />
config.action_mailer.smtp_settings = {<br />
   :enable_starttls_auto => true,<br />
   :address        => 'smtp.gmail.com',<br />
   :port           => 587,<br />
   :domain         => 'localhost.localdomain',<br />
   :authentication => :plain,<br />
   :user_name      => "username",<br />
   :password       => "password"<br />
}</code></p>
<p>This should work without any plugins/gems in rails 2.3.2. The only caveat is that ruby version has to be >= 1.8.7. It won&#8217;t work with ruby 1.8.6 or older, as documented <a href="https://rails.lighthouseapp.com/projects/8994/tickets/1336-starttls-for-smtp-makes-gmail-go">here</a>.</p>
<p>Enjoy!</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tatvartha.com/2009/05/actionmailer-gmail-and-tls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing passenger/mod_rails on CentOS</title>
		<link>http://www.tatvartha.com/2009/05/installing-passengermod_rails-on-centos/</link>
		<comments>http://www.tatvartha.com/2009/05/installing-passengermod_rails-on-centos/#comments</comments>
		<pubDate>Mon, 04 May 2009 21:16:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tatvartha.com/?p=110</guid>
		<description><![CDATA[Installing passenger/mod_rails on CentOS sometimes is not as simple as: $ gem install passenger and $ passenger-install-apache2-module In my case, I also had to install &#8220;apr-util-devel&#8221; yup package. Also, for some reason the &#8220;sudo yum install &#8221; didn&#8217;t work for me. I actually had to become root and then perform install. $ sudo su - [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Installing passenger/mod_rails on CentOS sometimes is not as simple as:</p>
<p><code><br />
$ gem install passenger<br />
and<br />
$ passenger-install-apache2-module<br />
</code></p>
<p>In my case, I also had to install &#8220;apr-util-devel&#8221; yup package. Also, for some reason the &#8220;sudo yum install
<package>&#8221; didn&#8217;t work for me. I actually had to become root and then perform install.</p>
<p><code><br />
$ sudo su -<br />
$ yum install apr-util-devel<br />
</code></p>
<p>After this, &#8220;gem install passenger&#8221; and passenger-apache module install worked fine.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tatvartha.com/2009/05/installing-passengermod_rails-on-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing mysql gem on CentOS</title>
		<link>http://www.tatvartha.com/2009/05/installing-mysql-gem-on-centos/</link>
		<comments>http://www.tatvartha.com/2009/05/installing-mysql-gem-on-centos/#comments</comments>
		<pubDate>Mon, 04 May 2009 16:26:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.tatvartha.com/?p=107</guid>
		<description><![CDATA[Installing mysql gem on cent-os may sometimes be not as easy as: $ gem install mysql It may result in compilation error and fail to install. While this may happen for various reasons, in my case, I had to install &#8220;mysql-devel&#8221; package. $ sudo yum install mysql-devel Once I did this, the mysql gem installed [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Installing mysql gem on cent-os may sometimes be not as easy as:</p>
<p><code>$ gem install mysql</code></p>
<p>It may result in compilation error and fail to install. While this may happen for various reasons, in my case, I had to install &#8220;mysql-devel&#8221; package.</p>
<p><code>$ sudo yum install mysql-devel</code></p>
<p>Once I did this, the mysql gem installed happily.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.tatvartha.com/2009/05/installing-mysql-gem-on-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

