<?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>Anlek Consulting &#187; Rails</title>
	<atom:link href="http://anlek.com/category/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://anlek.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Thu, 10 Nov 2011 16:29:24 +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>Wicked_PDF working in Rails 3.1</title>
		<link>http://anlek.com/2011/09/wicked_pdf-working-in-rails-3-1/</link>
		<comments>http://anlek.com/2011/09/wicked_pdf-working-in-rails-3-1/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 20:29:14 +0000</pubDate>
		<dc:creator>Andrew Kalek</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Wicked_PDF]]></category>
		<category><![CDATA[Rails 3.1]]></category>
		<category><![CDATA[wicked_pdf]]></category>

		<guid isPermaLink="false">http://anlek.com/?p=272</guid>
		<description><![CDATA[I recently updated one of my apps to Rails 3.1 and found that my PDF generating tests were failing because they were unable to find the CSS or images to use in the PDF. So I started playing around, and here is what I got: In your app, add a new initializer (or edit your [...]]]></description>
			<content:encoded><![CDATA[<p>I recently updated one of my apps to Rails 3.1 and found that my PDF generating tests were failing because they were unable to find the CSS or images to use in the PDF.</p>
<p>So I started playing around, and here is what I got:</p>
<p>In your app, add a new initializer (or edit your existing wicked_pdf.rb initializer) and put the following:<br />
<script src="https://gist.github.com/1218149.js?file=wicked_pdf.rb"></script></p>
<p>As you can see in the code, I also replaced the background urls with correct references, this is assuming that you&#8217;re keeping your CSS images in the same location as your normal images (which I don&#8217;t see a reason why not but of course you can always tweak the script)</p>
<h3>Possible Issues</h3>
<h4>Pow.cx</h4>
<p>I had one issue with my generated PDF using <a href="pow.cx">pow.cx</a>, my CPU would jump to 100% (on the pow process) and the page would timeout. After upgrading to the latest version of pow (0.3.2) using this command:</p>
<pre>curl get.pow.cx | sh</pre>
<p>I was able to see my PDFs without an issue.</p>
<h3>Additional Sources:</h3>
<p><a href="http://blog.phusion.nl/2011/08/14/rendering-rails-3-1-assets-to-string/" target="_blank">http://blog.phusion.nl/2011/08/14/rendering-rails-3-1-assets-to-string/</a></p>
<p><a href="https://github.com/mileszs/wicked_pdf/issues/48" target="_blank">https://github.com/mileszs/wicked_pdf/issues/48</a></p>
]]></content:encoded>
			<wfw:commentRss>http://anlek.com/2011/09/wicked_pdf-working-in-rails-3-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>MongoMapper &#8211; undefined method &#8216;reflect_on_association&#8217;</title>
		<link>http://anlek.com/2010/06/mongomapper-undefined-method-reflect_on_association/</link>
		<comments>http://anlek.com/2010/06/mongomapper-undefined-method-reflect_on_association/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 21:52:52 +0000</pubDate>
		<dc:creator>Andrew Kalek</dc:creator>
				<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[MongoMapper]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Ruby On Rails]]></category>

		<guid isPermaLink="false">http://blog.anlek.com/?p=171</guid>
		<description><![CDATA[Information Tidbit: If you&#8217;re using reflection_on_association with ActiveRecord and need to use it with MongoMapper, here is what you want to do: undefined method `reflect_on_association' for User:Class ActiveRecord: User.reflect_on_association(:posts).klass.new MongoMapper: User.associations[:posts].klass.new Mongoid: User.associations['posts'].klass.new notice the posts is a string, it will not work with a symbol UPDATE &#8211; (Apr 2011) Mongoid now follows ActiveRecord&#8217;s style [...]]]></description>
			<content:encoded><![CDATA[<h3>Information Tidbit:</h3>
<p>If you&#8217;re using reflection_on_association with ActiveRecord and need to use it with MongoMapper, here is what you want to do:</p>
<p><code>undefined method `reflect_on_association' for User:Class</code></p>
<p>ActiveRecord:<br />
<code>User.reflect_on_association(:posts).klass.new</code></p>
<p>MongoMapper:<br />
<code>User.associations[:posts].klass.new</code></p>
<p>Mongoid:</p>
<p><code>User.associations['posts'].klass.new</code><br />
<em>notice the posts is a string, it will not work with a symbol</em></p>
<p><strong>UPDATE &#8211; (Apr 2011) </strong>Mongoid now follows ActiveRecord&#8217;s style naming:</p>
<p><code>User.reflect_on_association(:posts).klass.new</code></p>
]]></content:encoded>
			<wfw:commentRss>http://anlek.com/2010/06/mongomapper-undefined-method-reflect_on_association/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Paperclip to work with MongoMapper</title>
		<link>http://anlek.com/2010/06/getting-paperclip-to-work-with-mongomapper/</link>
		<comments>http://anlek.com/2010/06/getting-paperclip-to-work-with-mongomapper/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 17:17:04 +0000</pubDate>
		<dc:creator>Andrew Kalek</dc:creator>
				<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[MongoMapper]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[paperclip]]></category>

		<guid isPermaLink="false">http://blog.anlek.com/?p=161</guid>
		<description><![CDATA[Last night I was trying really hard to get MongoMapper to work with Paperclip via GridFS and failed. It seems right now Paperclip or even CarrierWave are not ready to be used with the latest MongoMapper drivers and GridFS (and I needed to use the latest drivers due to Scopify). After giving up using GridFS, [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I was trying really hard to get MongoMapper to work with Paperclip via GridFS and failed. It seems right now <a href="http://github.com/thoughtbot/paperclip" target="_blank">Paperclip</a> or even <a href="http://github.com/jnicklas/carrierwave" target="_blank">CarrierWave</a> are not ready to be used with the latest MongoMapper drivers and GridFS (and I needed to use the latest drivers due to <a href="http://github.com/grosser/scopify" target="_blank">Scopify</a>).</p>
<p>After giving up using GridFS, I wanted to use Paperclip with MongoMapper with the normal file system and I found this <a title="Paperclip and MongoMapper" href="http://www.bencurtis.com/2009/08/paperclip-and-mongomapper/" target="_blank">article from Ben Curtis</a>, however with the latest version of Paperclip (version 2.3.1.1) and MongoMapper (version 0.7.6) I was unsuccessful, kept getting:</p>
<p><code>Anonymous modules have no name to be referenced by</code></p>
<p>After reading the backtrace and diving into the paperclip source code I noticed that it was trying to use the ActiveRecord.logger and since I&#8217;ve removed ActiveRecord from my app, it was failing (with the odd error).</p>
<p>After some tweaking of Ben&#8217;s code, I came up with this: <a href="http://gist.github.com/424158" target="_blank">http://gist.github.com/424158</a></p>
]]></content:encoded>
			<wfw:commentRss>http://anlek.com/2010/06/getting-paperclip-to-work-with-mongomapper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MongoMapper logging to Rails log</title>
		<link>http://anlek.com/2010/05/mongomapper-logging-to-rails-log/</link>
		<comments>http://anlek.com/2010/05/mongomapper-logging-to-rails-log/#comments</comments>
		<pubDate>Mon, 17 May 2010 01:35:12 +0000</pubDate>
		<dc:creator>Andrew Kalek</dc:creator>
				<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[MongoMapper]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.anlek.com/?p=152</guid>
		<description><![CDATA[I started playing around with MongoMapper for MongoDB and I have to say I&#8217;m loving it! Somehow it just feels so much easier to work with. However, I did have an issue with my code and needed to see whether or not MongoMapper was looking for account_id in my model. Since there is no sql [...]]]></description>
			<content:encoded><![CDATA[<p>I started playing around with <a title="MongoMapper Github page" href="http://github.com/jnunemaker/mongomapper" target="_blank">MongoMapper</a> for <a title="MongoDB Main Page" href="http://mongodb.org" target="_blank">MongoDB</a> and I have to say I&#8217;m loving it! Somehow it just feels so much easier to work with. However, I did have an issue with my code and needed to see whether or not MongoMapper was looking for account_id in my model. Since there is no sql to look at, I was looking for a way to see what MongoMapper was sending to MongoDB. Luckily the answer was very simple, in your connection string you just have to do this:</p>
<p><code>MongoMapper.connection = Mongo::Connection.new('localhost', 27017, :logger =&gt; Rails.logger)</code></p>
<p>This little tidbit came from <a title="Zyph | Martin Design Studios, LLC :: Blog :: MongoDB and MongoMapper Greatness" href="http://www.zyphmartin.com/blog/mongodb-and-mongomapper-greatness" target="_blank">Zyph blog post</a></p>
]]></content:encoded>
			<wfw:commentRss>http://anlek.com/2010/05/mongomapper-logging-to-rails-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>uninitialized constant Rails::Railtie</title>
		<link>http://anlek.com/2010/03/uninitialized-constant-railsrailtie/</link>
		<comments>http://anlek.com/2010/03/uninitialized-constant-railsrailtie/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 01:12:39 +0000</pubDate>
		<dc:creator>Andrew Kalek</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.anlek.com/?p=146</guid>
		<description><![CDATA[A few days ago my app just stopped working, after a quick google search I found a great site that explains why: Jamie van Dyke that pointed out that inherited_resources has now fully moved to Rails 3 and will no longer work on Rails 2.3 or lower. Now Jamie seems to point to use older [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago my app just stopped working, after a quick google search I found a great site that explains why:</p>
<p><a title="Jamie van Dyke" href="http://www.jamievandyke.com/post/378395109/uninitialized-constant-rails-railtie">Jamie van Dyke</a> that pointed out that inherited_resources has now fully moved to Rails 3 and will no longer work on Rails 2.3 or lower. Now Jamie seems to point to use older versions of the gem because they changed the code for Rails 3.0, however I feel that his versions aren&#8217;t the latest version you could be running. So I wanted to add my 2 cents by showing you what I use:</p>
<p>In my environment.rb make sure you have both these lines in:<br />
<code>config.gem "inherited_resources", :version =&gt; "1.0.2"<br />
config.gem "responders", :version =&gt; "0.4.2"</code><br />
Hope that helps some of you out!</p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://anlek.com/2010/03/uninitialized-constant-railsrailtie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>uninitialized constant Test::Unit::TestResult::TestResultFailureSupport Error</title>
		<link>http://anlek.com/2009/10/uninitialized-constant-test-unit-testresult-testresultfailuresupport-error/</link>
		<comments>http://anlek.com/2009/10/uninitialized-constant-test-unit-testresult-testresultfailuresupport-error/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 17:46:57 +0000</pubDate>
		<dc:creator>Andrew Kalek</dc:creator>
				<category><![CDATA[gem]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[RSpec]]></category>

		<guid isPermaLink="false">http://blog.anlek.com/?p=137</guid>
		<description><![CDATA[Today trying to run my RSpec tests and I get an odd error: uninitialized constant Test::Unit::TestResult::TestResultFailureSupport (NameError) /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:105:in `const_missing&#8217; /usr/local/lib/ruby/gems/1.8/gems/test-unit-2.0.3/lib/test/unit/testresult.rb:28 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require&#8217; /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require&#8217; /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:158:in `require&#8217; &#8230;. After doing some research online I found out that the issue is caused by Shoulda and Mocha being included in my app. It seems that if you put [...]]]></description>
			<content:encoded><![CDATA[<p>Today trying to run my RSpec tests and I get an odd error:</p>
<blockquote><p>uninitialized constant Test::Unit::TestResult::TestResultFailureSupport (NameError)<br />
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:105:in `const_missing&#8217;<br />
/usr/local/lib/ruby/gems/1.8/gems/test-unit-2.0.3/lib/test/unit/testresult.rb:28<br />
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require&#8217;<br />
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require&#8217;<br />
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:158:in `require&#8217;<br />
&#8230;.</p></blockquote>
<p>After doing some research online I found out that the issue is caused by Shoulda and Mocha being included in my app. It seems that if you put a gem dependence for Shoulda before Mocha,  you&#8217;ll get this error, so the <strong>fix</strong> is to place the gem dependence for Mocha before Shoulda.</p>
<blockquote><p>config.gem &#8220;rspec&#8221;, :lib =&gt; false, :version =&gt; &#8220;&gt;=1.2.6&#8243;<br />
config.gem &#8220;rspec-rails&#8221;, :lib =&gt; &#8216;spec/rails&#8217;, :version =&gt; &#8220;&gt;=1.2.6&#8243;<br />
config.gem &#8220;mocha&#8221;<br />
config.gem &#8220;thoughtbot-shoulda&#8221;, :lib =&gt; &#8220;shoulda&#8221;, :source =&gt; &#8220;http://gems.github.com&#8221;</p></blockquote>
<p>Hope that helps</p>
<p><strong>UPDATE:</strong></p>
<p>I hit the same error having shoulda in my environment.rb file, moving it to the test.rb (in environment folder) fixed the issue as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://anlek.com/2009/10/uninitialized-constant-test-unit-testresult-testresultfailuresupport-error/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Error with fsevent and autospec (on Mac)</title>
		<link>http://anlek.com/2009/10/error-with-fsevent-version-0-1-2-and-autospec/</link>
		<comments>http://anlek.com/2009/10/error-with-fsevent-version-0-1-2-and-autospec/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 05:16:18 +0000</pubDate>
		<dc:creator>Andrew Kalek</dc:creator>
				<category><![CDATA[gem]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[RSpec]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.anlek.com/?p=129</guid>
		<description><![CDATA[Today I&#8217;ve upgraded my gems and noticed that when running my autospec I get an odd error: [01:09:25 /usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.10/lib/ole/storage/base.rb:146:load] WARN   root name was &#8220;R&#8221; And my autospec would keep printing out: sh: line 1:  6303 Trace/BPT trap          /usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.1.2/fsevent/darwin/fsevent_sleep &#8216;/Users/andrew/rails_apps/example_com&#8217; 2&#62;&#38;1 sh: line 1:  6307 Trace/BPT trap         [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve upgraded my gems and noticed that when running my autospec I get an odd error:</p>
<blockquote><p>[01:09:25 /usr/local/lib/ruby/gems/1.8/gems/ruby-ole-1.2.10/lib/ole/storage/base.rb:146:load]</p>
<p>WARN   root name was &#8220;R&#8221;</p></blockquote>
<div>And my autospec would keep printing out:</div>
<div>
<blockquote>
<div>sh: line 1:  6303 Trace/BPT trap          /usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.1.2/fsevent/darwin/fsevent_sleep &#8216;/Users/andrew/rails_apps/example_com&#8217; 2&gt;&amp;1</div>
<div>sh: line 1:  6307 Trace/BPT trap          /usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.1.2/fsevent/darwin/fsevent_sleep &#8216;/Users/andrew/rails_apps/example_com&#8217; 2&gt;&amp;1</div>
</blockquote>
<div>Unfortunately I don&#8217;t have the time to look into the fsevent code to see if I can make a work around, however I found that you can remove the gem (&#8216;<strong><code>sudo gem uninstall autotest-fsevent</code></strong>&#8216;) and install the older version (&#8216;<strong><code>sudo gem install autotest-fsevent --version 0.1.1</code></strong>&#8216;)</div>
</div>
<div>Hopefully this helps someone out!</div>
<div><strong>UPDATE</strong>: I forgot to mention I was using a Mac OS X 10.5.8, and based on the <a href="http://github.com/svoop/autotest-fsevent/blob/master/History.txt" target="_blank">History.txt</a> they made changes effecting Macs.</div>
<div><strong>UPDATE 2 (Oct 22, 09):</strong> It seems that the same issue exists in fsevent 0.1.3 as well</div>
<div><strong>UPDATE 3 (Mar 05, 2010):</strong> Issue still present in 0.2.1 however I found out that the error is only for OS X 10.5 and will not happen on OS X 10.6.</div>
<div>The full error message is:</div>
<p><code>/usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.2.1/fsevent/darwin/fsevent_sleep ; exit;<br />
~%  /usr/local/lib/ruby/gems/1.8/gems/autotest-fsevent-0.2.1/fsevent/darwin/fsevent_sleep ; exit;<br />
dyld: unknown required load command 0x80000022<br />
zsh: trace trap</code></p>
<p><strong>The only work around (outside of downgrading to version 0.1.1) is to copy fsevent_sleep from version 0.1.1 to version 0.2.1. However I&#8217;m not sure how stable that solution is.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://anlek.com/2009/10/error-with-fsevent-version-0-1-2-and-autospec/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Setting Session Cookie across your whole domain (in Rails 2.3)</title>
		<link>http://anlek.com/2009/08/setting-session-cookie-across-your-whole-domain-in-rails-23/</link>
		<comments>http://anlek.com/2009/08/setting-session-cookie-across-your-whole-domain-in-rails-23/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 19:57:43 +0000</pubDate>
		<dc:creator>Andrew Kalek</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.anlek.com/?p=119</guid>
		<description><![CDATA[I have an application that has subdomains based on account (i.e. user1.example.com) but I want one login for the whole system, no matter what subdomain/account your in. In rails 2.2 I&#8217;d set it up by setting: ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_domain] = '.domain.com' Notice the leading &#8216;.&#8217; (very much needed) But in rails 2.3 it doesn&#8217;t work, so I [...]]]></description>
			<content:encoded><![CDATA[<p>I have an application that has subdomains based on account (i.e. user1.example.com) but I want one login for the whole system, no matter what subdomain/account your in. In rails 2.2 I&#8217;d set it up by setting:<br />
<code><br />
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_domain] = '.domain.com'<br />
</code><br />
<em>Notice the leading &#8216;.&#8217; </em>(very much needed)</p>
<p>But in rails 2.3 it doesn&#8217;t work, so I found from <a href="http://www.markgandolfo.com.au/archive" target="_blank">Mark Gandolfo</a> you can set it using:<br />
<code><br />
config.action_controller.session = {<br />
:session_key =&gt; '_my_session_id',<br />
:secret      =&gt; '..your_secret_code_here..',<br />
<strong>:domain =&gt; ".domain.com"</strong><br />
}<br />
</code></p>
<p>Hope that helps someone! <img src='http://anlek.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>UPDATE:</strong></p>
<p>If what I&#8217;m showing here is to simple for your needs, I did find a great post on how to deal with multiple domains (not just subdomains) in rails 2.3 at <a title="Code Tunes" href="http://codetunes.com/2009/04/17/dynamic-cookie-domains-with-racks-middleware/" target="_blank">Code Tunes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://anlek.com/2009/08/setting-session-cookie-across-your-whole-domain-in-rails-23/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 2.3 Templates on Windows</title>
		<link>http://anlek.com/2009/04/rails-templates/</link>
		<comments>http://anlek.com/2009/04/rails-templates/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 05:16:51 +0000</pubDate>
		<dc:creator>Andrew Kalek</dc:creator>
				<category><![CDATA[gem]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.anlek.com/?p=70</guid>
		<description><![CDATA[In Rails 2.3, templates are simple ruby files containing DSL for adding plugins, gems, initializers, etc. to your freshly created Rails project. To apply the template, you need to provide the rails generator with location of the template you wish to apply, using -m option. Reading up on the commands in the template system and [...]]]></description>
			<content:encoded><![CDATA[<p>In Rails 2.3, <a href="http://weblog.rubyonrails.org/2009/3/16/rails-2-3-templates-engines-rack-metal-much-more">templates</a> are simple ruby files containing DSL for adding plugins, gems, initializers, etc. to your freshly created Rails project. To apply the template, you need to provide the rails generator with location of the template you wish to apply, using -m option.</p>
<p>
<a href="http://m.onkey.org/2008/12/4/rails-templates">Reading up</a> on the commands in the template system and watching the <a href="http://railscasts.com/episodes/148-app-templates-in-rails-2-3">railscasts.com</a> episode, I got fired up on the possibilities of such a simple yet amazing system. So I dove in and started creating my base template. I was so excited that I write the whole template out in one go and than ran it. The result: <strong>FAIL</strong>!</p>
<p>
After including some gems, I ran a <code>rake "gems:install"</code> and ended up with an <code>Exec format error</code>. I googled the problem and found that mostly Windows users were getting this error and the recommend solution was to use a rake.bat (or rake.cmd) instead of the rake command from ruby. So I wrote my own function:<br />
<code><br />
#HELPERS<br />
def win_env?<br />
  RUBY_PLATFORM=~ /win32/<br />
end<br />
<br/>def rake(command, options = {})<br />
  env = options[:env] || 'development'<br />
  log 'rake', "#{command} in #{env} "<br />
  sudo = win_env?  ? '' : (options[:sudo] ? 'sudo' : '')<br />
  rake_cmd = win_env? ? "rake.bat" : 'rake'<br />
  in_root { run("#{sudo} #{rake_cmd} #{command} RAILS_ENV=#{env}", false) }<br />
end<br />
</code></p>
<p>Another thing that I was able to fix is the &#8220;Sudo&#8221; option, works great on UNIX systems but not so great in Windows. I haven&#8217;t been able to test it but I&#8217;m pretty sure this will work on a UNIX system without any issues.</p>
<p>All worked out great till I ran <code>run "cucumber features -n"</code> and got the exact same error! Lucky there was a .bat version of cucmber command so I was able to easily fix it by calling <code>run "cucumber#{win_env? ? '.bat': ''} features -n"</code></p>
<p>One more small issue I found in Windows when making a template was in the git command. When doing a commit you need to use double quotes inside the commit message otherwise you get an <code>error: pathspec 'commit'' did not match any file(s) known to git.</code></p>
<p>If you&#8217;re interested in downloading my template, you can download it from <a href="http://blog.anlek.com/wp-content/uploads/2009/04/base_template.rb">here</a></p>
<p>If you really want to see the power of template system I recommend you read the template_runner.rb in the rails folder. Enjoy and have fun with it!</p>
]]></content:encoded>
			<wfw:commentRss>http://anlek.com/2009/04/rails-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

