<?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>Activars.(evolving  and active) &#187; Ruby on Rails</title>
	<atom:link href="http://www.activars.com/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.activars.com</link>
	<description>tech, web, programming, rails</description>
	<lastBuildDate>Fri, 13 Aug 2010 01:41:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Pass JavaScript variables to Rails controller</title>
		<link>http://www.activars.com/2009/04/13/pass-javascript-variables-to-rails-controller/</link>
		<comments>http://www.activars.com/2009/04/13/pass-javascript-variables-to-rails-controller/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 18:40:58 +0000</pubDate>
		<dc:creator>jay</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://wp.activars.com/?p=77</guid>
		<description><![CDATA[Google query doesn&#8217;t give much useful result on this topic. What we discuss here is if there is a value/function getParameters() in JavaScript returns "message = hello_world" (a URL query). How do you pass the JS variable into controller? link_to_remote Most common way is using link_to_remote which constructs an Ajax call, but the drawback is [...]]]></description>
			<content:encoded><![CDATA[<p>Google query doesn&#8217;t give much useful result on this topic. What we discuss here is if there is a value/function <code>getParameters()</code> in JavaScript returns <code>"message = hello_world"</code> (a URL query). How do you pass the JS variable into controller?</p>
<h4>link_to_remote</h4>
<p>Most common way is using <code>link_to_remote</code> which constructs an Ajax call, but the drawback is you have to handle the <code>params[:message]</code> using RJS template (or please let me know if I was wrong). Here is the example:</p>
<script src="http://gist.github.com/509812.js"></script>
<p>As you see, the :with option will eventually become <code>:with => "message=hello_world"</code>. A new parameter is accessible by calling <code>params[:message]</code>. But what if I only want to render another page?</p>
<h4>capture block</h4>
<p>Capture block captures a variable for the view which can be reused. The idea is to call the JavaScript inside capture block to pass it as a Rails variable in view. The <code>@param</code> variable is readable in the view.</p>
<script src="http://gist.github.com/509818.js"></script>
<h4>link_to_function</h4>
<p>Remember that we have already passed the JavaScript value to <code>@param</code> variable, it is used here. An inline <code>redirect_to</code> does the trick, that redirects to the <code>new</code> action and value is accessible by calling <code>params[:message]</code>.</p>
<script src="http://gist.github.com/509820.js"></script>
<p>I&#8217;m sure that you will have other ways of using these tricks in difference situation, but hope you get the idea and use them whenever is suitable. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.activars.com/2009/04/13/pass-javascript-variables-to-rails-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing Rails restful_authentication in rspec</title>
		<link>http://www.activars.com/2009/02/16/passing-rails-restful_authentication-in-rspec/</link>
		<comments>http://www.activars.com/2009/02/16/passing-rails-restful_authentication-in-rspec/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 18:40:05 +0000</pubDate>
		<dc:creator>jay</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://wp.activars.com/?p=75</guid>
		<description><![CDATA[Plugins in Rails are useful shortcuts, they produce better implementations for some areas. I recently come across an issue of passing model controller authentication, but the before_filter :login_required stops me testing my code in Rspec. By using mock and stub technique can pass the authentication test. All you have to do is inserting these code [...]]]></description>
			<content:encoded><![CDATA[<p>Plugins in Rails are useful shortcuts, they produce better implementations for some areas. I recently come across an issue of passing model controller authentication, but the <code>before_filter :login_required</code> stops me testing my code in Rspec. By using mock and stub technique can pass the authentication test.<br />
All you have to do is inserting these code before your rspec test (or place it somewhere in helper class)</p>
<script src="http://gist.github.com/509827.js"></script>
<p>This tells the test that <code>:login_required</code> always returns <code>:true</code> and the variable <code>@current_user</code> returns a mock model that is not <code>nil</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.activars.com/2009/02/16/passing-rails-restful_authentication-in-rspec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Offline Rails Documentation</title>
		<link>http://www.activars.com/2009/02/01/offline-rails-documentation/</link>
		<comments>http://www.activars.com/2009/02/01/offline-rails-documentation/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 18:39:00 +0000</pubDate>
		<dc:creator>jay</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://wp.activars.com/?p=73</guid>
		<description><![CDATA[Although you can run gem server to have a rails rdoc running on localhost, the rdoc rails document could be troublesome to find a specific method you would like to know about. Fortunately, you may want to try out an ajax improved rails documentation: RailsBrain provides a free downloadable (free) offline documentation for rails. It [...]]]></description>
			<content:encoded><![CDATA[<p>Although you can run <code>gem server</code> to have a rails rdoc running on localhost, the rdoc rails document could be troublesome to find a specific method you would like to know about. Fortunately, you may want to try out an ajax improved rails documentation:</p>
<ul>
<li><a href="http://www.railsbrain.com/" target="_blank">RailsBrain</a> provides a free downloadable (free) offline documentation for rails. It has the lastest version 2.2.2 available for download. The ajax feature allows developer search method, class or file name via a input box. It&#8217;s a sufficient tool and I am using it now for development.</li>
<p></p>
<li><a href="http://www.gotapi.com/" target="_blank">Gotapi</a> is an online API collections. you can manage/view/search all the API you are currently using in any languages(e.g. PHP, Java, .net and of course rails). Similar features are privided as RailsBrains, but it&#8217;s only available online.</li>
<p></p>
<li><a href="http://www.railsapi.com/" target="_blank">Railsapi.com</a> is a recent new project and is hosted on <a href="http://www.github.com" target="_blank">GitHub</a>. It has better search capabilities. Intresting to note that it does not support Internet Explorer is currently (may be more specific version or not been IE tested). Apart from that, it&#8217;s smart, tidy and downloadable Rails doc. <em>(Added on March 24 2009)</em></li>
<p></p>
<li><a href="http://rails.raaum.org">rails.raaum.org</a> Taylor suggested a very compact Rails documentation site. It&#8217;s actually a site that lists some useful information for developers including good podcasts, links and posts. So check this out see if you can find any good topics.<em>(Added on July 21 2010)</em> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.activars.com/2009/02/01/offline-rails-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Fork Ruby&#8221; Summary (RubyConf 2008)</title>
		<link>http://www.activars.com/2008/12/30/fork-ruby-summary-rubyconf-2008/</link>
		<comments>http://www.activars.com/2008/12/30/fork-ruby-summary-rubyconf-2008/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 18:37:56 +0000</pubDate>
		<dc:creator>jay</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://wp.activars.com/?p=71</guid>
		<description><![CDATA[I like screencast and keynote, they are great ways of learning practically. But some people don&#8217;t have much time to watch or listen to all these. Or maybe you forgot some ideas were presented, but it&#8217;s difficult to select the part you want to find in the video &#8211; you end up with watching the [...]]]></description>
			<content:encoded><![CDATA[<p>I like screencast and keynote, they are great ways of learning practically. But some people don&#8217;t have much time to watch or listen to all these. Or maybe you forgot some ideas were presented, but it&#8217;s difficult to select the part you want to find in the video &#8211;  you end up with watching the video again sometimes. So here I typed in a short summary of the keynote.  If you are still interested, it&#8217;s worth to watching the video.  And thanks to David Thomas giving <a href="http://rubyconf2008.confreaks.com/keynote.html" target="_blank">this talk</a>.</p>
<p><strong>Presenter</strong>: David Thomas<br />
<strong>Background</strong>: Last RubyConf attended was in 2005, started working on Ruby back in 1999. He wrote books, talked at many events and went to a lot of conferences. HE recently went to many Rails conferences.</p>
<h3>Why Fork Ruby</h3>
<p>There are a lot of active project forking Ruby interpreter, e.g. <a href="http://jruby.codehaus.org/" target="_blank">JRuby</a>, <a href="http://www.ironruby.net/" target="_blank">IronRuby</a>, <a href="http://www.macruby.org/trac/wiki/MacRuby" target="_blank">MacRuby</a>, but they are not forking the Ruby language.</p>
<h3>Problem with Release Time</h3>
<p>1.0 -&gt; 1.2 tookk 14 months -&gt; 1.4 (8 months) -&gt; 1.6 (13 months) -&gt; 1.8 (48 months) -&gt; 1.9 (54 months)</p>
<ul>
<li> As you can see, bigger changes we make, the bigger challenges they are, more time required for next release.</li>
<li> The bigger changes make developer difficult to adopt to these new features.</li>
<li> Less people use the new release feature, release team will not be able to find problems.</li>
</ul>
<h3>Some (Potential) Projects Ideas</h3>
<h4>RubyLite</h4>
<p>RubyLite is a light version of Ruby. The idea is that moving those listed less used features into Gem,  developer install those gems only when they needed.</p>
<ul>
<li>One of  the things we can do with RubyLite is to lose some language features that we normally don&#8217;t use (e.g.):
<ul>
<li>%q delimiters</li>
<li>implicit string concatenation</li>
<li>alias</li>
<li>nested assignment</li>
<li><code>::</code> sign for method call</li>
</ul>
</li>
<li>And other features we can get rid of: class variables, global variables, many combination of <code>$</code> sign, <code>unless</code>/<code>until</code>, <code>protected</code>, <code>proc</code></li>
<li>One encoding will make library much smaller, so how about support utf8.</li>
<li>Losing Built-in classes and modules: <code>Complex</code>, <code>File::Stat</code>, <code>FileTest</code>, <code>Mutex</code>, <code>ObjectSpace</code>, <code>Process::Gid</code>/<code>Status</code>/<code>Sys</code>/<code>Uid</code>, <code>Rational</code>, <code>TreadGroup</code></li>
<li>Losing Built-in methods, a lot of methods are vibrations that produces the same result.</li>
</ul>
<h4>Parallel Ruby</h4>
<p>Ruby already have the construction to produce parallelism: <code>a, b = b, a</code></p>
<p>Ideally, Dave suggested that we could perform calculation using this parallel feature in separate threads or processes: <code>a, b = calc1(x), calc2(y)</code>. He used some sample code of finding longest word in English,  which demonstrated that a few lines code produced Map/Reduce.</p>
<h4>Optionally-typed Ruby</h4>
<h4>Closure-based Ruby</h4>
<p>This Is the Ruby with block, and it should be easy to create lambda. Suggestion is to remove <code>{}</code> sign for hash. Maybe we can express methods and classes in blocks.</p>
<h3>Conclusion</h3>
<p>There is nothing wrong with Ruby, &#8220;but that shouldn&#8217;t stop us from having fun&#8221;.  The community should fork Ruby and experiment with it. If the result is positive, they will be put in main Ruby release. The Ruby release itself should not be part of the experiment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.activars.com/2008/12/30/fork-ruby-summary-rubyconf-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configure Rails migration version type</title>
		<link>http://www.activars.com/2008/12/02/configure-rails-migration-version-type/</link>
		<comments>http://www.activars.com/2008/12/02/configure-rails-migration-version-type/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 18:34:38 +0000</pubDate>
		<dc:creator>jay</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://wp.activars.com/?p=65</guid>
		<description><![CDATA[Rails use a UTC time stamp as migration version by default. Although most examples in books have simple number based system for managing migration versions, there isn&#8217;t much information about version type configuration. By default, a migration file(&#62;=Rail 2.0) name look similar to: We can turn this off and use numeric prefixes by adding this [...]]]></description>
			<content:encoded><![CDATA[<p>Rails use a UTC time stamp as migration version by default. Although most examples in books have simple number based system for managing migration versions, there isn&#8217;t much information about version type configuration. By default, a migration file(&gt;=Rail 2.0) name look similar to:</p>
<script src="http://gist.github.com/509854.js"></script>
<p>We can turn this off and use numeric prefixes by adding this in <code>config/environment.rb</code></p>
<script src="http://gist.github.com/509857.js"></script>
<p>New generated file name will look like:</p>
<script src="http://gist.github.com/509859.js"></script>
<p>But bare in mind, if the Rails project is getting large and a few developers are working on same project, it&#8217;s likely that two developers generate same version of migration (e.g. 003). Using time stamp is introduced since Rail 2.0 to avoid such problem. So&#8230; better keep the default setting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.activars.com/2008/12/02/configure-rails-migration-version-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>config.gem &#8216;rspec-rails&#8217; on Rails 2.2.2</title>
		<link>http://www.activars.com/2008/11/29/config-gem-rspec-rails-on-rails-2-2-2/</link>
		<comments>http://www.activars.com/2008/11/29/config-gem-rspec-rails-on-rails-2-2-2/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 18:33:43 +0000</pubDate>
		<dc:creator>jay</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://wp.activars.com/?p=63</guid>
		<description><![CDATA[Update on 5th April 2009: This rspec-rails gem issue has been fixed and released in rspec-rails milestone “1.2.0”. see details here If you are still working on Rspec before version 1.20: After googling, I counld&#8217;t find much information about including rspec-rails in the ruby gems config/environment.rb. The only reason I include it in gem dependency [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update on 5th April 2009:</strong></p>
<p>This rspec-rails gem issue has been fixed and released in rspec-rails milestone <em class="change">“1.2.0”. <a href="http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/577" target="_blank">see details here</a><br />
</em></p>
<p><em class="change"></em><strong>If you are still working on Rspec before version 1.20:<br />
</strong></p>
<p>After googling, I counld&#8217;t find much information about including rspec-rails in the ruby gems config/environment.rb. The only reason I include it in gem dependency is for the sake of <a href="http://en.wikipedia.org/wiki/Continuous_integration" target="_blank">continuous integration</a>, to make sure the build platform happy and green.</p>
<p>So, back to the topic. This was related to rspec bug<span style="text-decoration: line-through;"> <a href="http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/577" target="_blank">#577</a> (still an open ticket)</span>, if placing the congif gem in this order:</p>
<script src="http://gist.github.com/509862.js"></script>
<p>you will likely to get errors:<br />
<script src="http://gist.github.com/509864.js"></script></p>
<p>The ways to get your head around the bug is placing the rspec-rails before the rspc:<br />
<script src="http://gist.github.com/509865.js"></script></p>
<p>Alternatively, only include rspec-rails would install rspec by default.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.activars.com/2008/11/29/config-gem-rspec-rails-on-rails-2-2-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RubyGem update on Leopard</title>
		<link>http://www.activars.com/2008/11/27/rubygem-update-on-leopard/</link>
		<comments>http://www.activars.com/2008/11/27/rubygem-update-on-leopard/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 18:31:52 +0000</pubDate>
		<dc:creator>jay</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://wp.activars.com/?p=61</guid>
		<description><![CDATA[I have a RubyGem version 1.2.0 installed on Leopard. If you would like to update RubyGems to a newer version, the RubyGem user guide suggests for modern versions( &#62;0.8.5 ) can use the following command: gem update --system But, console told me the 1.2.0 is the latest version &#8211; Nothing to update! The work around [...]]]></description>
			<content:encoded><![CDATA[<p>I have a RubyGem version 1.2.0 installed on Leopard. If you would like to update RubyGems to a newer version, the <a href="http://www.rubygems.org/read/book/1" target="_blank">RubyGem user guide </a>suggests for modern versions( &gt;0.8.5 ) can use the following command:</p>
<pre lang="shellscript">gem update --system</pre>
<p>But, console told me the 1.2.0 is the latest version &#8211; Nothing to update! The work around is to use install rubygem-update:</p>
<pre lang="shellscript">gem install rubygems-update
update_rubygems</pre>
<p>Check installed version:</p>
<pre lang="shellscript">MBP:~ Jay$ gem --version
1.3.1</pre>
<p>So now, I&#8217;m able to pull the latest <a href="http://rspec.info/" target="_blank">rSpec</a> plugin into my Rails project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.activars.com/2008/11/27/rubygem-update-on-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony and Ruby on Rail</title>
		<link>http://www.activars.com/2008/04/15/symfony-and-ruby-on-rail/</link>
		<comments>http://www.activars.com/2008/04/15/symfony-and-ruby-on-rail/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 18:00:05 +0000</pubDate>
		<dc:creator>jay</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://wp.activars.com/?p=12</guid>
		<description><![CDATA[研究过PHP下的Symfony, 再看Ruby on Rail的时候, 发现两者都有不少的相似性. 首先他们都用到MVC的架构设计整个项目， 作为Web Application来说， 这样可以将class library， layout view, handler清清楚楚的分开，有助于多人开发，和日常维护。 如果比较过两者library的结构，他们也有相近之处。 从创建项目到编辑项目设置等等。 比如， 创建项目时， 他们都会创建一系列的文件夹和默认文件， 然后可以自己创建module, 都有位置防止plugins。做数据库的时候，也可以用.xml 或者.yml导出 Sql store procedures. 那到底哪个比较好一些。 这里有一边文章对比一些MVC frameworks的性能， 不足的是, Bench mark只不过是一个参照, 完全不能说明其他的情况, 比如error handling的性能, 每个framework都有各自的优化设置, symfony deployment的时候就有优化的设置. 在Google doc上到有一片比较全面的文章比较Rail和Django, 对与一个新的项目选择framework有一定的帮助.]]></description>
			<content:encoded><![CDATA[<p>研究过PHP下的Symfony, 再看Ruby on Rail的时候, 发现两者都有不少的相似性.</p>
<p>首先他们都用到MVC的架构设计整个项目， 作为Web Application来说， 这样可以将class library， layout view, handler清清楚楚的分开，有助于多人开发，和日常维护。  如果比较过两者library的结构，他们也有相近之处。 从创建项目到编辑项目设置等等。 比如， 创建项目时， 他们都会创建一系列的文件夹和默认文件， 然后可以自己创建module, 都有位置防止plugins。做数据库的时候，也可以用.xml 或者.yml导出 Sql store procedures.</p>
<p>那到底哪个比较好一些。 这里有一边文章<a href="http://wiki.rubyonrails.org/rails/pages/Framework+Performance" target="_blank">对比一些MVC frameworks的性能</a>， 不足的是, Bench mark只不过是一个参照, 完全不能说明其他的情况, 比如error handling的性能, 每个framework都有各自的优化设置, <a href="http://www.symfony-project.com/book/trunk/deployment" target="_blank">symfony deployment的时候就有优化的设置</a>. 在Google doc上到有一片比较全面的文章<a href="http://docs.google.com/View?docid=dcn8282p_1hg4sr9" target="_blank">比较Rail和Django</a>, 对与一个新的项目选择framework有一定的帮助.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.activars.com/2008/04/15/symfony-and-ruby-on-rail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
