<?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>I On Rails</title>
	<atom:link href="http://ionrails.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ionrails.com</link>
	<description>Keeping an &#039;I&#039; on RoR</description>
	<lastBuildDate>Mon, 16 Aug 2010 15:16:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Perforce corrupts Scripts</title>
		<link>http://ionrails.com/2010/07/16/perforce-corrupts-scripts/</link>
		<comments>http://ionrails.com/2010/07/16/perforce-corrupts-scripts/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 22:09:01 +0000</pubDate>
		<dc:creator>navid</dc:creator>
				<category><![CDATA[Source Control]]></category>
		<category><![CDATA[client spec]]></category>
		<category><![CDATA[client specification]]></category>
		<category><![CDATA[line feed]]></category>
		<category><![CDATA[line feeds]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perforce]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://ionrails.com/?p=503</guid>
		<description><![CDATA[On windows, I am mapping a linux drive. So in Perforce, when I do a perforce sync, the files on linux will get updated. After doing this, vs doing a perforce sync on the command line on Linux itself, I noticed that the script/server and script/generate commands didn&#8217;t work without typing &#8220;ruby &#8221; in front [...]]]></description>
			<content:encoded><![CDATA[<p>On windows, I am mapping a linux drive. So in Perforce, when I do a perforce sync, the files on linux will get updated.<br />
After doing this, vs doing a perforce sync on the command line on Linux itself, I noticed that the script/server and script/generate commands didn&#8217;t work without typing &#8220;ruby &#8221; in front of them.</p>
<p>The way to solve this is problem is to edit your client spec in Perforce, on windows and set the LineItem drop-down from default to &#8220;unix&#8221; instead.<br />
This issue has to do with how line feeds differ on Windows vs Unix.</p>
]]></content:encoded>
			<wfw:commentRss>http://ionrails.com/2010/07/16/perforce-corrupts-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>auto_complete Plugin and Virtual Attributes</title>
		<link>http://ionrails.com/2010/06/26/auto_complete-plugin-and-virtual-attributes/</link>
		<comments>http://ionrails.com/2010/06/26/auto_complete-plugin-and-virtual-attributes/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 06:36:00 +0000</pubDate>
		<dc:creator>navid</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[VIew Related Plugins]]></category>
		<category><![CDATA[auto complete]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[virtual attributes]]></category>

		<guid isPermaLink="false">http://ionrails.com/?p=424</guid>
		<description><![CDATA[The way you normally specify which fields in your form should auto complete, is to add a declaration within your controller that looks like: auto_complete_for :model_name, :field_name However, this only works for actual fields that exist in your database, not for virtual attributes. So :field_name cannot be a virtual attribute, but should be a real [...]]]></description>
			<content:encoded><![CDATA[<p>The way you normally specify which fields in your form should auto complete, is to add a declaration within your controller that looks like:</p>
<pre class="brush: ruby;">auto_complete_for :model_name, :field_name</pre>
<p>However, this only works for actual fields that exist in your database, not for virtual attributes. So :field_name cannot be a virtual attribute, but should be a real existing database field.</p>
<p>The solution is to create a virtual attribute in your model, that&#8217;s a getter method. </p>
<p>Let&#8217;s say you want your users to lookup make and models of Cars that are in your database by entering text in your form&#8217;s text field and you want this <em>one</em> field to auto complete. Assume, however, that your database stores the make and model as separate fields. You decide to define a virtual attribute called &#8216;make_model&#8217; in your Car model.</p>
<p>* At this time, add some Car records in your database, if you don&#8217;t already have any, so you can actually test your work with the auto_complete plugin!</p>
<p>Let&#8217;s say you have a form in your erb with a text field called &#8216;make_model&#8217; which maps to a virtual attribute called &#8216;make_model&#8217; which will look like this:</p>
<pre class="brush: ruby;">
def make_model
make + ', ' + model if self
end
</pre>
<p>Your controller may look something like this:</p>
<pre class="brush: ruby;">
class CarsController &lt; ApplicationController

  # used by index.js.erb by auto_complete_result (autocomplete plugin)
  # there's three cases, if nothing is entered in the get request, the entire result is returned
  # If what the user enters contains a comma, assume make, model was typed in, otherwise, it could be
  # make or model.
  # The first letter of the make and model must be entered for lookup to happen.
  # This increases performance. Notice % is missing
  # from before #{make} and #{model}
  def index
    make_model_typed_in = params[:search]
    if make_model_type_in.blank?
      @cars = Cars.find(:all)
    elsif make_model_typed_in.include?(',')
      make_model_array = make_model_typed_in.split(',')
      make = make_model_array[0].strip
      model = make_model_array[1].strip
      @cars = Page.find(:all, :conditions =&gt; ['make LIKE ? and model LIKE ?', &quot;#{make}%&quot;, &quot;#{model}%&quot;], :order =&gt; 'make, model')
    else
      make = model = make_model_typed_in.strip
      @cars = Page.find(:all, :conditions =&gt; ['make LIKE ? or model LIKE ?', &quot;#{make}%&quot;, &quot;#{model}%&quot;], :order =&gt; 'make, model')
    end
  end
end
</pre>
<p>Now make the index action above be called via Javascript.<br />
Create an erb file called index.js.erb under views/cars/. It should contain the following:</p>
<pre class="brush: ruby;">
&lt;%= auto_complete_result @cars, :make_model %&gt;
</pre>
<p>Insert &#8216;debugger&#8217; method call in the actual method auto_complete_result definition to see what&#8217;s passed into it. Edit the vendor/plugins/auto_complete/lib/auto_complete_macros/helper.rb file. Here I assume you already have the ruby-debug gem properly installed. If not, install it now, make sure it works with your environment and learn how to use it.</p>
<p>It should look like this:</p>
<pre class="brush: ruby;">
  def auto_complete_result(entries, field, phrase = nil)
    return unless entries
    debugger
    items = entries.map { |entry| content_tag(&quot;li&quot;, phrase ? highlight(entry[field], phrase) : h(entry[field])) }
    content_tag(&quot;ul&quot;, items.uniq)
  end
</pre>
<p>Hit http://localhost:3000/cars.js and you should enter the (rdb:1) prompt.</p>
<p>The following returns nil which indicates that method auto_complete_result doesn&#8217;t know how to handle virtual attributes.</p>
<pre class="brush: ruby;">
(rdb:1) p entries[0][:make_model]
nil
</pre>
<p>However, you won&#8217;t get a nil returned if you access a &#8216;real&#8217; field that actually exists in your database.</p>
<pre class="brush: ruby;">
(rdb:1) p entries[0][:make]
BMW
</pre>
<p>So, the solution that worked for me (from <a href="http://www.ruby-forum.com/topic/155728">auto_complete_result field rather than method</a>) was to replace &quot;field&quot; with &quot;method&quot; in the method&#8217;s definition line and replace &quot;entry[field]&quot; to &quot;entry.send(method)&quot; in the method auto_complete_result within the auto_complete plugin&#8217;s code.  </p>
<p>So your method should look like this:</p>
<pre class="brush: ruby;">
  def auto_complete_result(entries, method, phrase = nil)
    return unless entries
    debugger
    items = entries.map { |entry| content_tag(&quot;li&quot;, phrase ? highlight(entry.send(method), phrase) : h(entry.send(method))) }
    content_tag(&quot;ul&quot;, items.uniq)
  end
</pre>
<p>Now if you hit http://localhost:3000/cars.js you should get all of your make_model returned in &lt;LI&gt; tags inside a &lt;UL&gt; tag.</p>
]]></content:encoded>
			<wfw:commentRss>http://ionrails.com/2010/06/26/auto_complete-plugin-and-virtual-attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Routes</title>
		<link>http://ionrails.com/2010/06/23/debugging-routes/</link>
		<comments>http://ionrails.com/2010/06/23/debugging-routes/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 04:48:53 +0000</pubDate>
		<dc:creator>navid</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[routes]]></category>

		<guid isPermaLink="false">http://ionrails.com/?p=420</guid>
		<description><![CDATA[ruby script/console To see how an external request would map to your internal path: &#62;&#62;rs = ActionController::Routing::Routes Sample: &#62;&#62;rs.recognize_path &#34;/controller/action/id&#34;, :method =&#62; :get To reload routes.rb if you made changes to it: ActionController::Routing::Routes.reload &#8212;- To generate a path use generate method: &#62;&#62;rs.generate :controller =&#62; &#34;controllername&#34;, :action =&#62; &#34;actionname&#34;, :id =&#62; 123, :extra =&#62; &#34;extrastuff&#34; =&#62; [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: ruby;">ruby script/console</pre>
<p>To see how an external request would map to your internal path:</p>
<pre class="brush: ruby;">&gt;&gt;rs = ActionController::Routing::Routes</pre>
<p>Sample:</p>
<pre class="brush: ruby;">&gt;&gt;rs.recognize_path &quot;/controller/action/id&quot;, :method =&gt; :get</pre>
<p>To reload routes.rb if you made changes to it: ActionController::Routing::Routes.reload</p>
<p>&#8212;-</p>
<p>To generate a path use generate method:</p>
<pre class="brush: ruby;">&gt;&gt;rs.generate :controller =&gt; &quot;controllername&quot;, :action =&gt; &quot;actionname&quot;, :id =&gt; 123, :extra =&gt; &quot;extrastuff&quot;
=&gt; &quot;/controllername/actionname/123?extra=extrastuff&quot;</pre>
]]></content:encoded>
			<wfw:commentRss>http://ionrails.com/2010/06/23/debugging-routes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wym_Editor (WYSIWYM) Plugin for Rails</title>
		<link>http://ionrails.com/2010/06/18/wym_editor-wysiwym-plugin-for-rails/</link>
		<comments>http://ionrails.com/2010/06/18/wym_editor-wysiwym-plugin-for-rails/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 18:32:30 +0000</pubDate>
		<dc:creator>navid</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[wymeditor]]></category>
		<category><![CDATA[wym_editor]]></category>
		<category><![CDATA[wysiwyg]]></category>

		<guid isPermaLink="false">http://ionrails.com/?p=404</guid>
		<description><![CDATA[The wym_editor (WYSIWYM &#8211; &#8220;What you see is what you mean&#8221;) plugin is pretty cool. It allows you to define which form fields you want to offer WYSIWYM editing functionality. This makes it easier for you to edit fields and give them styles. It also allows you to see the HTML source view while you [...]]]></description>
			<content:encoded><![CDATA[<p>The wym_editor (WYSIWYM &#8211; &#8220;What you see is what you mean&#8221;) plugin is pretty cool. It allows you to define which form fields you want to offer WYSIWYM editing functionality. This makes it easier for you to edit fields and give them styles. It also allows you to see the HTML source view while you see the browser view.</p>
<p>The code that wym_editor generates is strict XHTML code.</p>
<p>Of course, you can use CSS to style the tags that are generated. I&#8217;m looking for a plugin that allows you to copy over the contents from a field of one record to the same field of another record. If you know of any plugins/gems designed for this, please let me know. Otherwise, I&#8217;ll just create an entry that is used as a template and copy what I want from that record. </p>
<p>Here is how to install the wym_editor plugin:</p>
<ol>
<li>script/plugin install svn://zuurstof.openminds.be/home/kaizer/svn/rails_stuff/plugins/wym_editor_helper</li>
<li>rake wym:install</li>
<li>In your layout&#8217;s HEAD tag, add &#8221;  &lt;%= yield :head %&gt;</li>
<li>In each page (erb file), you want you plan on using wym_editor, add the following once at the top: &lt;% content_for :head do %&gt; &lt;%= wym_editor_initialize %&gt;&lt;% end %&gt;</li>
<li>To each form field that you want to provide WYSIWYM editing functionality, add :class =>&#8217;wymeditor&#8217;. In my case, I added this functionality to the description field and so my erb entry looks like: &lt;%= f.text_area :description, :class => &#8216;wymeditor&#8217; %&gt;</li>
<li>Add :class => &#8216;wymupdate&#8217; to your Submit button. In my edit.html.erb file, my update button looks like: &lt;%= f.submit &#8216;Update&#8217;, :class => &#8216;wymupdate&#8217; %&gt;</li>
</ol>
<p>Here is a screenshot of what the Edit page looks like:</p>
<p><img src="http://ionrails.com/wp-content/uploads/2010/06/wym.gif" alt="wym_editor (WYSIWYG Plugin for Rails)" height="450" width="400" />
<p>If you want to use the &quot;Silver&quot; skin for wymeditor, you can add the following in your layout file&#8217;s head tag:</p>
<pre class="brush: ruby;">
  &lt;!-- Here are all the WYMEDITOR javascript includes. This replaces yield :head --&gt;
  &lt;%= javascript_include_tag '/wymeditor/jquery/jquery' %&gt;
  &lt;%= javascript_include_tag '/wymeditor/wymeditor/jquery.wymeditor.js' %&gt;
  &lt;%= javascript_include_tag '/wymeditor/wymeditor/jquery.wymeditor.explorer.js' %&gt;
  &lt;%= javascript_include_tag '/wymeditor/wymeditor/jquery.wymeditor.mozilla.js' %&gt;
  &lt;%= javascript_include_tag '/wymeditor/wymeditor/jquery.wymeditor.opera.js' %&gt;
  &lt;%= javascript_include_tag '/wymeditor/wymeditor/jquery.wymeditor.safari.js' %&gt;
  &lt;%= javascript_include_tag '/wymeditor/wymeditor/lang/en' %&gt;

  &lt;script type=&quot;text/javascript&quot;&gt;
  jQuery(function() {
    jQuery('.wymeditor').wymeditor({
	  skin: 'silver'
	});
  });
  &lt;/script&gt;
</pre>
<p>So, what I ended up doing is omitting the yield :head line from my head tag and replaced it with the above so I import the javascript files explicitly. The reason why I did this is because by default there are references to screen.css file but it doesn&#8217;t exist. Also, I found that when I was trying to use the Silver skin, my page would render two of each textbox, one would use the Silver skin and one wouldn&#8217;t. There is probably a much nicer solution but this one works, and I&#8217;m fine with it for now. If anyone can tell me what the elegant solution is, please feel free to comment. So, one thing to be aware of is that I also ended up omitting the boot_wym.js file. Before explicitly importing your javascript VS deciding to using the yield :head entry, first use yield :head and view your source code and note down what javascripts/css are being imported!</p>
<p>Also be aware that if you are already importing a different version of jquery.js, you should remove the following entry:</p>
<pre class="brush: ruby;">
  &lt;%= javascript_include_tag '/wymeditor/jquery/jquery' %&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ionrails.com/2010/06/18/wym_editor-wysiwym-plugin-for-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SET data type in MySQL and ActiveRecord</title>
		<link>http://ionrails.com/2010/06/16/set-data-type-mysql-activerecord/</link>
		<comments>http://ionrails.com/2010/06/16/set-data-type-mysql-activerecord/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 22:17:40 +0000</pubDate>
		<dc:creator>navid</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[checkboxes]]></category>
		<category><![CDATA[SET]]></category>
		<category><![CDATA[SET data type]]></category>

		<guid isPermaLink="false">http://ionrails.com/?p=397</guid>
		<description><![CDATA[I figured out something cool which solves a common database design problem. However, I&#8217;m not sure if this is supported in ActiveRecord since the SET data type does not exist in all databases. Let&#8217;s say each record in a table has zero or more properties and your set of properties is pre-defined. How would you [...]]]></description>
			<content:encoded><![CDATA[<p>I figured out something cool which solves a common database design problem. However, I&#8217;m not sure if this is supported in ActiveRecord since the SET data type does not exist in all databases.</p>
<p>Let&#8217;s say each record in a table has zero or more properties and your set of properties is pre-defined.<br />
How would you implement this in MySQL? Maybe it&#8217;s possible to do what I&#8217;m about to say in other databases as well? If so, please comment.</p>
<p>Use the SET data type in MySQL to solve this problem. Imagine you have a bunch of checkboxes in your HTML form which define the properties of each record of your table.</p>
<p>By using the SET data type, you can simplify your database design and, ultimately help increase performance too!</p>
<p>mysql has a SET data type. You can define what properties you want for a particular column and it will use only one bit per property. For example, each column in the <em>Cars</em> table can store one or more of these attributes. I believe in the database, it&#8217;s stored as a binary field of 1&#8242;s and 0&#8242;s like 1010100000 and the 1s and 0s are mapped to the SET we defined when we created the table!</p>
<p>Try out the following six statements in MySQL:</p>
<pre class="brush: sql;">
CREATE DATABASE test;
CREATE TABLE car ( option SET ('sports', 'sunroof', 'spoiler', 'turbo', 'leather', 'power-steering', 'diesel') );
INSERT INTO car (option) VALUES ('sports,turbo,power-steering');
INSERT INTO car (option) VALUES ('leather,power-steering,diesel');
INSERT INTO car (option) VALUES ('spoiler,diesel');
SELECT * FROM car;
</pre>
<p>Be sure you don&#8217;t put any spaces after the commas in your INSERT statements!</p>
<p>How do you use the SET data type in ActiveRecord? I haven&#8217;t used this yet in a real world application yet. Once I figure out how to use it with ActiveRecord, I will update this entry. In the meantime, feel free to post comments and examples.</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://ionrails.com/2010/06/16/set-data-type-mysql-activerecord/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dealing with Money in Rails</title>
		<link>http://ionrails.com/2010/06/16/money-in-rails/</link>
		<comments>http://ionrails.com/2010/06/16/money-in-rails/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 21:49:32 +0000</pubDate>
		<dc:creator>navid</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[cents]]></category>
		<category><![CDATA[decimal]]></category>
		<category><![CDATA[integer]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[Money Gem]]></category>
		<category><![CDATA[money_column gem]]></category>
		<category><![CDATA[price]]></category>

		<guid isPermaLink="false">http://ionrails.com/?p=393</guid>
		<description><![CDATA[In process of determining how to handle fields such as price, in Rails, I&#8217;ve conducted some research. There seems to be a debate on whether to use decimal or integer as the price field. In case of where integer data types are used, the integer actually will store the price in cents. One argument for [...]]]></description>
			<content:encoded><![CDATA[<p>In process of determining how to handle fields such as price, in Rails, I&#8217;ve conducted some research. There seems to be a debate on whether to use decimal or integer as the price field. In case of where integer data types are used, the integer actually will store the price in cents. </p>
<p>One argument for using an integer data type instead of decimal, for the price field, is the idea that decimal can cause precision errors during calculations. However, I&#8217;ve heard that decimal data types are used successfully at Banks so I don&#8217;t believe this argument (yet).</p>
<p>The reason I&#8217;m leaning towards using decimal as the price is that probably 99% of the time, you&#8217;ll need to display the price in decimal format, not integer. You just have to remember to only do the math with BigDecimal ruby type. This translates to decimal data type in the database. BigDecimal stores the number and fractional part of the decimal as integers anyway, is what I hear. Can someone comment on this?</p>
<p>If you&#8217;d like to go with storing the price as a integer, then I recommend using the Money gem. If you&#8217;d like to go with storing the price as a decimal field, then I recommend using the money_column gem found at <a href="http://github.com/tobi/money_column">Money Column Gem</a>. </p>
<p>My colleague and I discovered that it&#8217;s difficult to validate to ensure that only a numeric value can be entered. The reason: the Money gem converts any non-numeric value to 0 cents. I&#8217;ve been trying to validate the price as it&#8217;s entered by the user, before it&#8217;s converted to cents. I believe a virtual attributes (getter and setter) must be created for the price field and converted to cents, so that money :price declaration cannot be used. However, I haven&#8217;t yet been able to get this to work, mainly because I switched over to thinking that maybe I should be storing the price in decimal type in the database anyway. This is when I switched over to using the money_column gem instead.</p>
<p>With the money_column gem, I realized that non-numeric price values are converted to 0.0, instead of like nil and I still cannot get my rspec test to pass because yes 0.0 is a 0 or greater and also yes, it exists! I emailed the author of the money_column gem and he suggested I modify the code to be able to allow it to return nil for non-numeric values, as long as it doesn&#8217;t break existing code. I don&#8217;t want to invest too much time in doing this yet. If anyone has a suggestion, please feel free to comment. Apparently, the money_column gem has been extracted from Shopify&#8217;s code and has been used successfully for a while, so I believe both solutions are doable. However, I&#8217;d like to hear from developers who have tried both routes and hear pros and cons to both.</p>
<p>So I did a bunch of research on this and it sort of boils down to this.</p>
<p>BigDecimal in ruby maps to decimal datatype in the database as I mentioned above.<br />
It can be used succesfully for price. </p>
<p>I think the main argument in using integer for price is to avoid potential bugs in the way the decimal price field is used. For example, someone can forget and try to convert the decimal price field to a float using the to_f method.</p>
<p>For example, try this in script/console: BigDecimal(&#8220;10.03&#8243;).to_f<br />
It spits out 10.3 which is a rounding error.<br />
So some solutions are to write tests! and to redefine or remove the to_f method in BigDecimal. Most of the bugs on the internet around this have to do with forgetting and trying to convert to a float.</p>
<pre class="brush: ruby;">class BigDecimal; undef :to_f; end;</pre>
<p>OR</p>
<pre class="brush: ruby;">class BigDecimal; def to_f; self.to_s.to_f; end; end</pre>
<p>OR </p>
<p>redefine the to_f method to have it throw an Exception whenever it is used in order to lessen chances of running into this issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://ionrails.com/2010/06/16/money-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RVM and Frozen Rails Conflict</title>
		<link>http://ionrails.com/2010/03/12/rvm-frozen-rails-conflict/</link>
		<comments>http://ionrails.com/2010/03/12/rvm-frozen-rails-conflict/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 21:29:48 +0000</pubDate>
		<dc:creator>navid</dc:creator>
				<category><![CDATA[Installing]]></category>
		<category><![CDATA[Rails Versioning]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[managing gems]]></category>
		<category><![CDATA[rails version]]></category>
		<category><![CDATA[rails versions]]></category>
		<category><![CDATA[ruby version]]></category>
		<category><![CDATA[ruby versions]]></category>
		<category><![CDATA[rvm]]></category>
		<category><![CDATA[rvm and frozen rails]]></category>

		<guid isPermaLink="false">http://ionrails.com/?p=361</guid>
		<description><![CDATA[I have an existing rails application and want to switch to using RVM in order to tie particular versions of Ruby, Rails and RubyGems to this application. My existing Rails application has a frozen Rails version 2.2.2 tied into it and so exists in my vendor/rails directory. Before I installed RVM, the following question came [...]]]></description>
			<content:encoded><![CDATA[<p>I have an existing rails application and want to switch to using RVM in order to tie particular versions of Ruby, Rails and RubyGems to this application. My existing Rails application has a frozen Rails version 2.2.2 tied into it and so exists in my vendor/rails directory.</p>
<p>Before I installed RVM, the following question came into my mind:<br />
How do you take an existing Rails app and determine which gems and versions it uses?<br />
I don&#8217;t know the answer yet but do have one solution as described below.</p>
<p>I&#8217;d like to use the Bundler gem but really need to know which gems to specify in the Gemfile, which sits in the root of my rails application directory. So, my goal here is to use RVM to reconstruct the list of gems by adding one gem at a time into my application and troubleshoot. Eventually, I&#8217;ll come up with a list of gems my app requires and assuming I&#8217;m successful, I can use that list to construct the Gemfile for Bundler.</p>
<p>Initially when you install RVM, you start with a clean slate, meaning your gem list won&#8217;t show any installed gems for a particular ruby version you&#8217;ve installed into your .rvm directory via the rvm command. Prior to RVM you would have all of these gems installed but it was very difficult to know which gems exactly you used in your app. I&#8217;m hoping that I can not only tie a set of gems to a particular ruby version but I&#8217;d like to associate a particular ruby, rails and gem version to each particular application. I hope RVM will support this. Still playing around with it to find out. Feel free to comment below. Thanks!</p>
<h2 class="navid_content">Installing RVM and Reinstalling Ruby, Rails and RubyGems for RVM</h2>
<ol>
<li>Install RVM from GitHub Repository as indicated here http://rvm.beginrescueend.com/rvm/install/</li>
<li>rvm install 1.9.1; rvm 1.9.1 &#8211;default (&#8211;default makes it so 1.9.1 will be your default version, in other new shells you open up as well)</li>
<li>remember if you want to switch back to your system Ruby, Rails and RubyGems, just type: rvm system. To switch to 1.9.1, for example, again, just type rvm use 1.9.1</li>
<li>gem install rails (notice when you are installing gems under rvm, you should NOT type &#8216;sudo&#8217;)</li>
</ol>
<h2 class="navid_content">You may notice the following RVM and frozen rails conflict</h2>
<pre class="brush: ruby;">
navid@~/Development/yourapp: script/server
/Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require': no such file to load -- test/unit/error (MissingSourceFile)
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `block in require'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/deprecation.rb:224:in `&lt;top (required)&gt;'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `block in require'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
	from /Users/navid/Development/yourapp/vendor/rails/activesupport/lib/active_support.rb:37:in `&lt;top (required)&gt;'
	from /Users/navid/Development/yourapp/vendor/rails/railties/lib/commands/server.rb:1:in `require'
	from /Users/navid/Development/yourapp/vendor/rails/railties/lib/commands/server.rb:1:in `&lt;top (required)&gt;'
	from script/server:3:in `require'
	from script/server:3:in `&lt;main&gt;'
</pre>
<h2 class="navid_content">Frozen Rails version tied to your application will conflict with RVM</h2>
<p>Solution: remove the frozen rails version from your application while in your system settings (i.e. while in your non RVM settings).</p>
<p>So, I did steps 1 through 4 above and then typed script/server in my rails application&#8217;s root directory and noticed conflicts because I had frozen rails 2.2.2 into my application earlier.  </p>
<p>So, the solution is to unfreeze rails from the application which basically deletes the /vendor/rails directory.</p>
<p>With RVM, I also am hoping that freezing the rails versions into an application is no longer needed and actually should not be done, or else you&#8217;ll run into this conflict.</p>
<p>However, keep in mind, you&#8217;ll probably run into a similar issue if you try to unfreeze rails while in you RVM environment, if RVM is conflicting with the frozen rails. </p>
<p>So the best thing to do is the following, revert back to your system settings, unfreeze rails and then come back to your rvm environment:</p>
<ol>
<li>rvm system</li>
<li>rake rails:unfreeze</li>
<li>rvm use default or rvm use 1.9.1</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://ionrails.com/2010/03/12/rvm-frozen-rails-conflict/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiline Comments in Rails ERB Views</title>
		<link>http://ionrails.com/2010/02/05/multiline-comments-in-rails-erb-views/</link>
		<comments>http://ionrails.com/2010/02/05/multiline-comments-in-rails-erb-views/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 07:17:16 +0000</pubDate>
		<dc:creator>navid</dc:creator>
				<category><![CDATA[Views]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[erb]]></category>
		<category><![CDATA[multiline comments]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://ionrails.com/?p=358</guid>
		<description><![CDATA[If you want to add multiline comments to your Rails .html.erb Views do the following. The =begin and =end need to be at the beginning of the lines for it to work! Also, you cannot have any ERB code in the =begin and =end blocks, if you comment this way. &#60;% =begin This is a [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to add multiline comments to your Rails .html.erb Views do the following.<br />
The =begin and =end need to be at the beginning of the lines for it to work!<br />
Also, you cannot have any ERB code in the =begin and =end blocks, if you comment this way.</p>
<pre class="brush: ruby;">
&lt;%
=begin
This is a multiline comment you can add to your .html.erb files.
Whatever you place in these comments won't show up in your rendered HTML.
You now have a place to put comments in your views. This will help
you better understand what you did later on.
=end %&gt;
</pre>
<p>If you want to comment out ERB code, you can do something like this, but you have to do it for each line. Just add -# to each line. For example, if you want to comment out this call to render a partial, do the following:</p>
<pre class="brush: ruby;">
&lt;%-#= render :partial =&gt; &quot;configuration&quot;, :locals =&gt; {:host =&gt; host } %&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ionrails.com/2010/02/05/multiline-comments-in-rails-erb-views/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby File Path Separators</title>
		<link>http://ionrails.com/2010/02/01/ruby-file-path-separators/</link>
		<comments>http://ionrails.com/2010/02/01/ruby-file-path-separators/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 01:33:30 +0000</pubDate>
		<dc:creator>navid</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[file path separators]]></category>

		<guid isPermaLink="false">http://ionrails.com/?p=350</guid>
		<description><![CDATA[File path separators on Unix systems and Windows are different. On Unix, a forward slash / is used and on Windows a backslash \ is used. However, when writing Ruby code you don&#8217;t need to worry about this; Just use the forward slash / character and it will be cross-platform for you. An even better [...]]]></description>
			<content:encoded><![CDATA[<p>File path separators on Unix systems and Windows are different. On Unix, a forward slash / is used and on Windows a backslash \ is used. </p>
<p>However, when writing Ruby code you don&#8217;t need to worry about this; Just use the forward slash / character and it will be cross-platform for you.</p>
<p>An even better option is to use File.join to join a paths together. The correct file path separator for the particular platform will be used. See <a href="http://ruby-doc.org/core/classes/File.html#M002545">File.join</a></p>
<p>When using the File.join method for absolute paths, the first argument to the join method must be an empty string.</p>
]]></content:encoded>
			<wfw:commentRss>http://ionrails.com/2010/02/01/ruby-file-path-separators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Instance and Class Variable Accessor Methods</title>
		<link>http://ionrails.com/2010/02/01/instance-and-class-variable-accessor-methods/</link>
		<comments>http://ionrails.com/2010/02/01/instance-and-class-variable-accessor-methods/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 06:42:58 +0000</pubDate>
		<dc:creator>navid</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[methods]]></category>
		<category><![CDATA[accessor methods]]></category>
		<category><![CDATA[attribute methods]]></category>
		<category><![CDATA[reader methods]]></category>
		<category><![CDATA[writer methods]]></category>

		<guid isPermaLink="false">http://ionrails.com/?p=340</guid>
		<description><![CDATA[When you define classes in Ruby, you must specify what kind of access you want to give Instance and Class attributes/variables which are defined in that class. The way you do it is that you write reader and writer methods. You can write these methods out explicitly or use the shorthand attribute (attr_) methods like [...]]]></description>
			<content:encoded><![CDATA[<p>When you define classes in Ruby, you must specify what kind of access you want to give Instance and Class attributes/variables which are defined in that class.</p>
<p>The way you do it is that you write reader and writer methods. You can write these methods out explicitly or use the shorthand attribute (attr_) methods like attr_reader, attr_writer and attr_accessor. These are methods defined in core Ruby. </p>
<p>However, in Ruby, there is no equivalent attr methods to read and write Class variables, at least none that I know of. Luckily, they are defined in Rails though and are called cattr_reader, cattr_writer and cattr_accessor. Be sure to test it out using script/console. You won&#8217;t be able to try it out in irb since irb uses Ruby not the Rails libraries.</p>
]]></content:encoded>
			<wfw:commentRss>http://ionrails.com/2010/02/01/instance-and-class-variable-accessor-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
