<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>rubyonrails &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/rubyonrails/</link>
	<description>Feed of posts on WordPress.com tagged "rubyonrails"</description>
	<pubDate>Fri, 25 Dec 2009 22:27:14 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Menggunakan CMS atau Framework?]]></title>
<link>http://r1dh0angg0r0.wordpress.com/2009/11/30/menggunakan-cms-atau-framework/</link>
<pubDate>Mon, 30 Nov 2009 14:17:52 +0000</pubDate>
<dc:creator>Ridho Anggoro</dc:creator>
<guid>http://r1dh0angg0r0.wordpress.com/2009/11/30/menggunakan-cms-atau-framework/</guid>
<description><![CDATA[Saya termasuk orang yang mengembangkan website tanpa pernah membuatnya dari nol. Maksudnya, saya tid]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Saya termasuk orang yang mengembangkan website tanpa pernah membuatnya dari nol. Maksudnya, saya tidak membuat komponen dari website itu secara manual satu demi satu. Mulai dari arsitektur website, komponen modul, file uploader, user access, image manager, dll. Biasanya semua dilakukan dengan menggunakan <a href="http://blog.iorme.net/blog/post/tentang_model_view_controller">CMS</a> yang OpenSource, seperti <a href="http://wordpress.org/">WordPress</a> dan <a href="http://drupal.org/">Drupal</a> (jaman dulu juga termasuk PHPNuke). Biasanya memang saya melakukan modifikasi disana – sini agar website ini bisa bekerja sesuai keinginan. Umumnya akhirnya website tersebut akhirnya bisa berjalan sesuai harapan.</p>
<p>Tetapi kemudian datang masalah seperti berikut ini :</p>
<ol>
<li>Website tersebut membutuhkan galery foto dengan fasilitas slideshow.</li>
<li>Website tersebut membutuhkan katalog produk.</li>
<li>Website tersebut ingin mengimplementasikan fasilitas social network.</li>
<li>Website itu ingin menyediakan fasilitas bagi membernya untuk bisa mengupload file MP3. Dan tiap member nantinya bisa mengatur level akses terhadap file MP3 yang dia upload.</li>
<li>Website tersebut ingin mempunyai form yang terintegrasi untuk arsip wawancara.</li>
<li>dll</li>
</ol>
<p>Jika saya menggunakan CMS seperti Drupal. Mungkin hal ini masih bisa ditangani dengan ketersediaan modulnya yang sangat banyak. Atau jika memang modulnya belum tersedia, kita bisa membuat sendiri. Selain itu jika kurang puas, kita masih bisa melakukan oprek lebih dalam dengan menggunakan <a href="http://en.wikipedia.org/wiki/Application_programming_interface">API</a> yang disediakan Drupal. Dengan tujuan agar website ini sesuai dengan apa yang kita inginkan.</p>
<p>Tetapi, hal ini bisa jadi merupakan masalah baru. Tentunya kadangkala hal ini bisa menjadi solusi untuk satu masalah tetapi bukan tidak jarang malah menimbulkan masalah baru. Beberapa skenario yang sering terjadi :</p>
<ol>
<li>Modul untuk <a href="http://id.wikipedia.org/wiki/Sistem_manajemen_konten">CMS</a> tersedia. Tetapi ada bagian yang tidak sesuai, bahkan mungkin ada bagian yang akhirnya malah terasa mengganggu. Misal modul e-commerce dari Drupal menyediakan begitu banyak fasilitas yang pada kenyataannya tidak saya butuhkan. Sedangkan untuk beberapa bagian justru masih belum sesuai harapan. Dan untuk bisa merubah modul ini, kita harus memahami hampir kesuluruhan struktur modul ini. Ditambah pengetahuan tentang API dari Drupal.</li>
<li>Terlalu banyak pilihan modul. Misal modul untuk upload gambar di Drupal. Secara default tidak ada. Kita masih bisa menginstal modul tambahan, sehingga nantinya <a href="http://drupal.org/project/imagepicker">upload gambar di Drupal akan semudah di WordPress</a>. Tetapi ketika sampai di tahap theming, saya menyadari bahwa field untuk gambar hasil upload modul tersebut tidak bisa diakse langsung. Berbeda dengan image yang diupload menggunakan bantuan module <a href="http://drupal.org/project/imagefield">Image Field (CCK)</a>.</li>
<li>Dengan <a href="http://api.drupal.org/">API</a> yang disediakan, kadangkala kita masih membutuhkan pengetahuan tentang API lain. Dan pada akhirnya mau tidak mau saya harus mempelajari banyak API, hanya untuk mengetahui bagian mana dari API ini yang tepat untuk solusi masalah saya.</li>
<li>Salah satu hal yang paling sulit adalah merubah alur kerja dari website ini. Misal jika user ingin register, tidaklah langsung ditampilkan ke halaman register, tetapi harus melalui satu halaman polling terlebih dahulu. Untuk bisa mengimplementasikan ini, secara tidak langsung kita harus tahu alur kerja (workflow) dari CMS yang kita gunakan.</li>
<li>Butuh field yang custom untuk tiap post (tidak hanya field TITLE dan POST saja). Secara default WordPress menyediakan fasilitas Custom Fields, tetapi penggunaannya masih belum senyaman CCK di Drupal. Untuk itu harus dibuat modul sendiri.</li>
<li>dll</li>
</ol>
<p>Jika memang akhirnya saya ingin menjadi <a href="http://lullabot.com/">ahli dari CMS</a> tersebut, saya rasa tidak masalah untuk mengikuti solusi yang saya berikan di atas. Tetapi jika saya hanya ingin menggunakan CMS ini sebagai bantuan, sepertinya effort nya terlalu besar.</p>
<p>Bahkan tidak jarang saya merasa, ketika mempelajari semua API, hook, templating, konvensi, dll dari suatu CMS, effortnya mungkin sama besarnya dengan jika saya membangun website tersebut dari nol.</p>
<p>Jadi apakah akhirnya membuat CMS dari nol?</p>
<p>Tidak. Bagi saya tetap tidak. Karena ada beberapa kemudahan di CMS yang tidak saya dapatkan jika saya harus membangun dari nol. Saya harus membangun kerangka / arsitektur dari website tersebut. Dan cukup banyak pula waktu yang tersita untuk membangunnya.</p>
<p>Jadi apa solusinya?</p>
<p>Framework. Bagi saya solusi di tengah – tengahnya adalah framework. Framework menjadi solusi yang tepat jika saya ingin mengembangkan website yang berbasis konten, tetapi dengan beberapa fasilitas yang tidak umum (seperti kasus di atas tadi). Dengan framework yang tepat, saya bisa membuat API saya sendiri, tetap mendapatkan fasilitas templating secara default, fasilitas layering untuk database, dan salah satu yang paling saya sukai adalah fasilitas URL Friendly secara default. Saya tidak tahu apakah semua framework menyediakan fasilitas tersebut, tetapi yang jelas Framework yang saya pakai (CodeIgniter) menggunakannya.</p>
<p>Pilihan framework yang cukup terkenal :</p>
<ol>
<li><a href="http://www.pradosoft.com/">Prado</a> – PHP (contoh : <a href="http://www.ui.edu/">website Univertias Indonesia</a>) : Kalau tidak salah ini seperti menjadi ASP.Net pada PHP</li>
<li><a href="http://codeigniter.com/">CodeIgniter</a> –  PHP(contoh : <a href="http://okezone.com/">OkeZone.com</a>), Jujur saja, saya tahu CodeIgniter dari situs OkeZone ini, dan sampai saat ini paling nyaman menggunakan ini, karena framework ini terdokumentasi dengan baik.</li>
<li><a href="http://www.rubyonrails.org/">Ruby On Rails</a> – Ruby (contoh : <a href="http://sharingfoto.com/">SharingFoto.com</a>) : Situs ini diklaim sebagai web aplikasi pertama di Indonesia yang menggunakan Ruby On Rails.</li>
<li><a href="http://cakephp.org/">CakePHP</a> – PHP (contoh : <a href="http://owncafe.com/">OwnCafe.com</a>) : Salah seorang yang sangat aktif dalam edukasi CakePHP di Indonesia adalah <a href="http://azzam.wordpress.com/">Sunu Wibirama</a> (alumni Teknik Elektro UGM). Situs lokal cake-php bisa dilihat di <a href="http://idcake.web.id/">idcake.web.id</a></li>
<li><a href="http://www.symfony-project.org/">Symfony</a> (PHP), <a href="http://www.djangoproject.com/">Django</a> (Python), dll</li>
</ol>
<p>Saya sendiri masih penasaran dan menantikan Mambo CMS versi 5.0 yang akan menggunakan CakePHP sebagai basisnya. Dengan kondisi seperti itu, maka level kustomisasi bisa dilakukan dari tingkat yang paling dasar (langsung menggunakan framework),di lapis tengah (modul), maupun lapis akhir (theming).</p>
<p>Jika ada yang tertarik dengan framework – framework di atas, jangan lupa pahami satu istilah ini : <a href="http://www.id-joomla.com/content/view/182/41/">MVC (Model View Controller)</a></p>
<p>&#160;</p>
<p>source: <a title="http://okto.silaban.net/2008/02/website/menggunakan-cms-atau-framework/" href="http://okto.silaban.net/2008/02/website/menggunakan-cms-atau-framework/" target="_blank">http://okto.silaban.net/2008/02/website/menggunakan-cms-atau-framework/</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby On Rails - Live DataGrid]]></title>
<link>http://ninadpachpute.wordpress.com/2009/11/22/ruby-on-rails-live-datagrid/</link>
<pubDate>Sun, 22 Nov 2009 14:31:27 +0000</pubDate>
<dc:creator>ninadp</dc:creator>
<guid>http://ninadpachpute.wordpress.com/2009/11/22/ruby-on-rails-live-datagrid/</guid>
<description><![CDATA[I just found this one &#8211; Creating a Live Datagrid Very neat and works well too&#8230; I still h]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I just found this one &#8211; <a href="http://unspace.ca/discover/datagrid">Creating a Live Datagrid</a></p>
<p>Very neat and works well too&#8230; I still have to check out how it works!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Posting on Face Book Using Third Party Application ruby]]></title>
<link>http://rorudhaya.wordpress.com/2009/11/20/posting-on-face-book-using-third-party-application-ruby/</link>
<pubDate>Fri, 20 Nov 2009 10:35:20 +0000</pubDate>
<dc:creator>rorudhaya</dc:creator>
<guid>http://rorudhaya.wordpress.com/2009/11/20/posting-on-face-book-using-third-party-application-ruby/</guid>
<description><![CDATA[REQUIREMENT: Ruby and RubyGems Facebooker gem A Facebook Account A Facebook Developer Account/Access]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>REQUIREMENT</strong>:</p>
<p>Ruby and RubyGems<br />
Facebooker gem<br />
A Facebook Account<br />
A Facebook Developer Account/Access</p>
<p><strong>Step-1</strong><br />
login to the facebook developers account using</p>
<p>http://developers.facebook.com/get_started.php</p>
<p><strong>Step-2</strong></p>
<ul>
<li>In that page just click Go to the Facebook Developer App</li>
<li>It will ask for Username and Password , enter the username and password and click login</li>
<li>Now you will be logged in . In that click Set up new application  Button</li>
<li>Now you will be entered in to create app page</li>
<li>In that enter your application name and check the agree check box and click save changes</li>
<li>Now you have created a new application now face book will provide application id , api key and secretkey in the basic tab of that page take note of it</li>
</ul>
<p><strong>Step-3</strong></p>
<ul>
<li>Now click the authentication link on that page</li>
<li>You will be moving to authentication page in that check the facebook page check box and click save change button</li>
<li>It will be redirect to application  page in that click edit setting it will move to application setting page</li>
<li>Now click the Canvas link</li>
<li>You will be moving to Canvas page . In taht in canvas page url enter the name of the application and in the canvas call back url enter the application url and click save changes</li>
<li>Now you have been sucessfully created an application and it will be redirect to My application page in that you will be getting details about the application take note of it</li>
<li>Now click view application link in that page</li>
<li>It will take you to the application page which you have craeted</li>
<li>In that page click more and click add to my page link and add the application to your page</li>
</ul>
<p><strong>Step-4</strong></p>
<ul>
<li>Now type to this url with your api key                             <strong>http://www.facebook.com/login.php?api_key=YOUR_API_KEY</strong> ,It will be moved to the application canvas call back url which you have created</li>
<li>Now type to this url with your api key                        <strong>http://www.facebook.com/code_gen.php?v=1.0&#38;api_key=YOUR_API_KEY </strong>,now you will be redirecting to Save my login info page</li>
<li>In that click generate to create a toke , This toke is more important for generating the session key this token in one time validity so dont use for any other part in you application except for creating session key</li>
<li>Now type this in the addressbar                                     <strong>http://www.facebook.com/authorize.php?api_key=YOUR_API_KEY&#38;v=1.0&#38;ext_perm=publish_stream</strong> ,it will redirecto facebook authorised page in that click allow button this</li>
<li>will give permission to post in the wall of your face book</li>
</ul>
<p><strong>Step-5</strong></p>
<p>Now open the comand prompt and check for all the ruby gems installed including facebooker gem and type</p>
<p>require &#8220;rubygems&#8221;<br />
require &#8220;facebooker&#8221;<br />
fb_session = Facebooker::Session.create(&#8220;apikey&#8221;, &#8220;secretkey&#8221;)<br />
#now you have assigned all the keys to the fb_session object</p>
<p><strong>Step-</strong>6</p>
<p>fb_session.post &#8220;facebook.auth.getSession&#8221;, :auth_token =&#62; &#8220;token&#8221;<br />
Now you have created a session key like this<br />
{&#8220;session_key&#8221;=&#62;&#8221;session key&#8221;, &#8220;expires&#8221;=&#62;&#8221;0&#8243;, &#8220;uid&#8221;=&#62;&#8221;user id&#8221;}</p>
<p><strong>Step-7</strong></p>
<p>Now type this in  your comand prompt</p>
<p><strong>fb_session.post(&#8220;facebook.stream.publish&#8221;, :message =&#62; &#8216;Hai this is test from ROR Team &#8216;,:session_key =&#62; &#8220;sessionkey&#8221; ,:target_id =&#62; &#8220;targetted it&#8221;)</strong></p>
<p>Now open you face book as normal user and you can able to see the message <strong>Hai this is test from ROR Team</strong> in the home wall</p>
<p>So We Can sucessfully post in The wall of Face Book From Third party application</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Instalação do RubyOnRails - BillVoip]]></title>
<link>http://helderam.wordpress.com/2009/11/15/instalacao-do-rubyonrails-completo/</link>
<pubDate>Sun, 15 Nov 2009 02:23:58 +0000</pubDate>
<dc:creator>Helder Morais</dc:creator>
<guid>http://helderam.wordpress.com/2009/11/15/instalacao-do-rubyonrails-completo/</guid>
<description><![CDATA[Instalar os pacotes do Ubuntu primeiro: sudo apt-get install ruby ruby-dev rubygems sudo apt-get ins]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Instalar os pacotes do Ubuntu primeiro:</p>
<blockquote><p>
sudo apt-get install ruby ruby-dev rubygems<br />
sudo apt-get install libopenssl-ruby<br />
sudo apt-get install mongrel
</p></blockquote>
<p>Depois instalar os gems</p>
<blockquote><p>
sudo gem install -v=1.2.3 rails<br />
sudo gem install -v=1.2.3 net-ping<br />
sudo gem install -v=2.0.11 net-ssh<br />
sudo gem install -v=2.0.2 net-sftp<br />
sudo gem install ruby-debug<br />
sudo gem install fastercsv</p>
</blockquote>
<p>Para instalar os scripts como serviços</p>
<blockquote><p>
 sudo update-rc.d mongreld_xxx defaults
</p></blockquote>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Thinking sphinx CJK support experiment]]></title>
<link>http://wilkinho.wordpress.com/2009/11/05/thinking-sphinx-cjk-support-experiment/</link>
<pubDate>Thu, 05 Nov 2009 13:41:49 +0000</pubDate>
<dc:creator>Wilkin Ho</dc:creator>
<guid>http://wilkinho.wordpress.com/2009/11/05/thinking-sphinx-cjk-support-experiment/</guid>
<description><![CDATA[Currently in my rails project, solr and act_as_solr is used as the search engine of the app. As act_]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Currently in my rails project, <a href="http://lucene.apache.org/solr/">solr</a> and <a href="http://github.com/railsfreaks/acts_as_solr/">act_as_solr</a> is used as the search engine of the app. As act_as_solr&#8217;s original author has stopped further development and the google group community seems inactive, I would like to try to look for alternatives.</p>
<p>I tried to switch to <a href="http://www.sphinxsearch.com">sphinx</a> and <a href="http://freelancing-god.github.com/ts/en/">thinking_sphinx</a>. I downloaded the <a href="http://www.sphinxsearch.com/downloads/sphinx-0.9.8.1.tar.gz">source</a> of sphinx 0.9.8.1 and built smoothly on my Mac development machine with snow leopard as my MySQL installation is not by Macports, or you can install sphinx directly from Macports. With the guidelines in thinking_sphinx website, everything goes fine. I installed the gem, added some codes in models, ran the rake tasks and I can start to search.</p>
<p>Then I need to deal with CJK support in my search. Parameters charset_table and ngram_char is need to be set in config file to facilitate this function. I found the charset table list in sphinx <a href="http://www.sphinxsearch.com/wiki/doku.php?id=charset_tables">wiki</a>. For charset_table, I combined the &#8220;common&#8221; list and &#8220;cjk&#8221; list, and it is a huge list. I spent sometime to add this list to the RAILS_ROOT/config/sphinx.yml file. The yml parser will throw &#8220;line too long&#8221; exception if I paste the list in a single line. I have the make the list in multiline, I tried to google around but the samples of other users just don&#8217;t work for me &#8211; the parser still can&#8217;t parse and throw exception. On the other hand, as thinking_sphinx generates a RAILS_ROOT/config/development.sphinx.conf file base on sphinx.yml, I have to make the list in multiline in the conf file too because sphinx cannot handle a too-long-line in conf file also. Finally, here is my current working sphinx.yml:</p>
<p><code>development:<br />
sql_range_step: 10000000 #handle fixture random id<br />
min_word_len: 1<br />
min_infix_len: 1<br />
ngram_len: 1<br />
enable_star: true<br />
ngram_chars: #...<br />
<span style="color:#ff0000;">charset_table:</span> "U+FF10..U+FF19-&#62;0..9, ..., 0..9, A..Z-&#62;a..z, a..z, <span style="color:#ff0000;">\\\n \</span><br />
U+F900-&#62;U+8C48, ..., U+F904-&#62;U+6ED1, <span style="color:#ff0000;">\\\n \</span><br />
#...<br />
U+AC00..U+D7A3, ..., U+A000..U+A48C, <span style="color:#ff0000;">\\\n \</span><br />
U+A492..U+A4C6"</code></p>
<h3>Testing</h3>
<p>Full width alphanumeric: works, use &#8220;ｈａｐｐｙ&#8221;, &#8220;２００９&#8221; can find &#8220;happy 2009&#8243;</p>
<p>Traditional &#38; Simplified Chinese: works, can search with single character/multi characters/single word/multi words</p>
<p>Korean: works, same as above</p>
<p>Japanese: partially work, sometimes fail to search with single kana character. For example, searching &#8220;あ&#8221; (a)/ &#8220;あい&#8221; (ai)/ &#8220;あいう&#8221; (aiu) cannot find &#8220;あいうえお&#8221; (aiueo) but search with &#8220;あいうえお&#8221; works. Searching &#8220;バカ&#8221; (BAKA) or &#8220;め&#8221; (me) can find &#8220;バカめ&#8221; (BAKAme) (Note: sorry for bad words&#8230;lol). Furthermore, this <a href="http://crunchytoast.com/2009/04/14/sphinx-search-in-japanese/">link</a> introduces charset table handling mapping of hiragana, katakana and half width katakana, which is useful in Japanese searching.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Rubyenrails 2009: what's in it for the customer?]]></title>
<link>http://blog.drivingthevortex.nl/2009/11/01/rubyenrails-2009-whats-in-it-for-the-customer/</link>
<pubDate>Sun, 01 Nov 2009 13:21:12 +0000</pubDate>
<dc:creator>Rob van Dijk</dc:creator>
<guid>http://blog.drivingthevortex.nl/2009/11/01/rubyenrails-2009-whats-in-it-for-the-customer/</guid>
<description><![CDATA[The Rubyenrails 2009 Conference, held in Amsterdam as previous years, has just finished. What was ne]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>The Rubyenrails 2009 Conference, held in Amsterdam as previous years, has just finished. What was new, what was hot and what&#8217;s in it for the customer?</p>
<p>One of the nice surprises was the increasing number of large(r) companies that are using Ruby on Rails, to name some examples: Tele2, Nedap, Ordina. Adoption of Rails varies from usage in one department to being the strategic platform of choice.</p>
<p>This nicely coincides with  the inspiring talk by Jeremy Kemper who observes that both Ruby and Rails are not hypes anymore but are becoming mainstream.</p>
<p>The real-life example <a title="Nederlandse Omroep" href="http://www.omroep.nl" target="_blank">omroep.nl</a> (presentation by Bart Zonneveld and Sjoerd Tieleman) illustrates what Ruby on Rails can do for the web development industry. Within 6 months a small team built both the site itself and a custom CMS that interfaces with an existing image library. If anything, this example shows both the maturity of the platform and the rapid development cycles that can be achieved.</p>
<p>Other presentations addressed performance (Bart ten Brinke) and security (Jonathan Weiss). They gave various practical pointers for building a performing Ruby on Rails site and increasing security to block various types of attacks (XSS, Session Fixation, CSRF, Javascript Hijacking).</p>
<p>Customers usually don&#8217;t care much which database is being used, as long as the functionality of the website works as desired. Perhaps this will be different for MongoDB (presentation by Michael Dirolf), a new document-based schema-free database. Letting go of schemas is quite a step for anybody involved in modern relational databases but it opens up a huge potential for flexibility all the way up to the end-user. An administrator wants a new User field for sub-departments? With MongoDB at the back this will be trivial. Sure, such functionality is possible with a relational database as well, but requires quite a bit more work.</p>
<p>Last but not least Jeremy Kemper and Yehuda Katz highlighted the improvements that Rails 3.0 will bring. Many excellent changes are of technical nature and invisible to customers but the speed-up of the framework (up to 10x for collection rendering) and the improved support for encoding and time zones will likely have a noticable effect on the (international) user experience.</p>
<p>What is your take on the advantages Rails 3.0 will bring?</p>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:581px;width:1px;height:1px;"><strong>Yehuda KatzJeremy Kemper and<br />
</strong></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Notes on ihower's rails best practice presentation]]></title>
<link>http://wilkinho.wordpress.com/2009/10/29/notes-on-ihowers-rails-best-practice-presentation/</link>
<pubDate>Wed, 28 Oct 2009 16:06:30 +0000</pubDate>
<dc:creator>Wilkin Ho</dc:creator>
<guid>http://wilkinho.wordpress.com/2009/10/29/notes-on-ihowers-rails-best-practice-presentation/</guid>
<description><![CDATA[original Prologue Test your code Move code from Controller to Model Move finder to named_scope Use m]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://ihower.idv.tw/blog/archives/3075">original</a></p>
<p>Prologue</p>
<ol>
<li>Test your code</li>
</ol>
<p>Move code from Controller to Model</p>
<ol>
<li>Move finder to named_scope</li>
<li>Use model association</li>
<li>Use scope access</li>
<li>Add model virtual attribute</li>
<li>Use model callback</li>
<li>Replace complex creation with factory method</li>
<li>Move model logic into the model</li>
<li>model.collection_model_ids (many-to-many)</li>
<li>Nested model forms (one-to-one) &#8211; accepts_nested_attribute_for</li>
<li>Nested model forms (one-to-many) &#8211; accepts_nested_attribute_for</li>
</ol>
<p>RESTful</p>
<ol>
<li>Overuse route customization &#8211; map.resources &#8230;</li>
<li>Needless deep nesting</li>
<li>Do not use default route</li>
</ol>
<p>Model</p>
<ol>
<li>Keep finder in their own model</li>
<li>Love named_scope</li>
<li><a href="http://en.wikipedia.org/wiki/Law_of_Demeter">The Law of Demeter</a> (LoD) &#8211; delegate</li>
<li>DRY: metaprogramming</li>
<li>Extract into Module</li>
<li>Extract to composed class &#8211; composed_of</li>
<li>Use observer</li>
</ol>
<p>Migration</p>
<ol>
<li>Isolating seed data</li>
<li>Always add DB index</li>
</ol>
<p>Controller</p>
<ol>
<li>Use before_filter</li>
<li>DRY controller &#8211; <a href="http://github.com/josevalim/inherited_resources">InheritedResources</a></li>
</ol>
<p>View &#8211; &#8220;Never logic code in views&#8221;</p>
<ol>
<li>Move code to controller</li>
<li>Move code to model</li>
<li>Move code to helper</li>
<li>Replace instance variables with local variables &#8211; render :partial =&#62; &#8230;, :locals =&#62;&#8230;</li>
<li>Use form builder</li>
<li>Organize helper files</li>
<li>Learn rails helpers &#8211; content_for, yield, pass block parameter in helper</li>
</ol>
<p>Code Refactoring</p>
<ol>
<li>The book &#8211; &#8220;Refactoring Ruby Edition&#8221;</li>
</ol>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[10 steps to get start with MySpace Ruby SDK]]></title>
<link>http://funonrails.wordpress.com/2009/10/27/10-steps-to-get-start-with-myspace-ruby-sdk/</link>
<pubDate>Tue, 27 Oct 2009 10:33:23 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/10/27/10-steps-to-get-start-with-myspace-ruby-sdk/</guid>
<description><![CDATA[Follow 10 simple steps in order to use myspace sdk api 1. Remove all your previous gems installed + ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Follow 10 simple steps in order to use myspace sdk api</p>
<p>1. Remove all your previous gems installed<br />
+ gem uninstall myspace</p>
<p>2. Checkout sample source code</p>
<p>svn checkout http://myspaceid-ruby-sdk.googlecode.com/svn/trunk/ myspacesdk</p>
<p>3. cd myspacesdk/samples/rails/sample<br />
4. Modify config/database.yml accordingly</p>
<blockquote>
<div>development:<br />
adapter: mysql<br />
database: sample_development<br />
password: abcd<br />
pool: 5<br />
timeout: 5000</div>
</blockquote>
<p>5. Download http://myspaceid-ruby-sdk.googlecode.com/files/myspaceid-sdk-0.1.11.gem<br />
6. gem install &#8211;local ~/Desktop/myspaceid-sdk-0.1.11.gem i.e.PATH_TO_GEM<br />
7. Above command supposed to give you following error otherwise skip to step 10</p>
<blockquote>
<div>ERROR:  Error installing /home/sandip/Desktop/myspaceid-sdk-0.1.11.gem:<br />
myspaceid-sdk requires ruby-openid (&#62;= 0, runtime)</div>
</blockquote>
<p>8. gem install ruby-openid go to step 6<br />
9. ruby script/server<br />
10. Browse http://localhost:3000/</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Aprendiendo Rails Part.1]]></title>
<link>http://ismaelmarin.wordpress.com/2009/10/24/aprendiendo-rails-part-1/</link>
<pubDate>Sat, 24 Oct 2009 10:33:38 +0000</pubDate>
<dc:creator>macguillermo</dc:creator>
<guid>http://ismaelmarin.wordpress.com/2009/10/24/aprendiendo-rails-part-1/</guid>
<description><![CDATA[En diciembre del 2007 el framework de desarrollo Ruby on Rails sufrió una actualización de gran impo]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div style="text-align:justify;">En diciembre del 2007 el framework de desarrollo <a href="http://www.rubyonrails.org/">Ruby on Rails</a> sufrió una actualización de gran importancia a su framework el ahora<a href="http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done"> Rails 2.0</a> , ahora bien, me he dado a la tarea de buscar información principalmente para los &#8220;Novatos&#8221; interesados en aprender este framework así como tutoriales en español, como se podrán imaginar sin mucha suerte, esta es la razón de la creación de este Blog, en el cual tratare de enseñar a poder sacar provecho de este framework así como la conjugación con el increíblemente potente y versátil lenguaje de programación <a href="http://www.ruby-lang.org/es/">Ruby</a>.</p>
<p>Ahora bien primero que nada algo que me apasiona sobre este framework es el hecho de adoptar una serie de tecnologías así como metodologias de programación las cuales nos permiten tener una mejor programación y control sobre el que será nuestro control sobre el resultado final y lo mejor de todo, es bastante divertido, continuación doy una pequeña explicación:</p>
<p><a href="http://es.wikipedia.org/wiki/Modelo_Vista_Controlador">MVC</a> (<span style="font-weight:bold;">Modelo &#8211; Vista &#8211; Controlador</span>), esta es una metodología de programación la cual nos da como premisa el hecho de estructurar nuestro código en base a tres partes funcionales, las cuales se estructuran de la siguiente forma:</div>
<div style="text-align:justify;"><span style="font-weight:bold;">El modelo</span> es donde nos permite tener un control de nuestros datos así como  la manipulación de estos, la <span style="font-weight:bold;">Vista</span> es la <a title="Interfaz de usuario" href="http://es.wikipedia.org/wiki/Interfaz_de_usuario">interfaz de usuario</a> esta se basa principalmente en la interacción directa aquí es donde aplicamos principalmente tecnologías como <a href="http://www.w3c.es/divulgacion/guiasbreves/HojasEstilo">CSS</a>, <a href="http://es.wikipedia.org/wiki/C%C3%B3digo_HTML">HTML</a> y <a href="http://es.wikipedia.org/wiki/JavaScript">Javascript</a> (<a href="http://es.wikipedia.org/wiki/AJAX">AJAX</a>), y por ultimo tenemos a el <span style="font-weight:bold;">Controlador</span> que es la <a title="Lógica de control" href="http://es.wikipedia.org/wiki/L%C3%B3gica_de_control">lógica de control</a> de nuestro programa es nuestro pegamento dentro de la interacción de la <span style="font-weight:bold;">Vista</span> y el <span style="font-weight:bold;">Modelo</span>, a continuación presento un pequeño esquema de como trabaja una aplicación mediante le uso de <a href="http://www.rubyonrails.org/">Ruby on Rails</a>.</div>
<div style="text-align:center;"><a href="http://2.bp.blogspot.com/_IJSFA7nl84U/SAV8oOwuubI/AAAAAAAAAPc/kklas9BZn8E/s1600-h/MVC.png"><img style="cursor:pointer;" src="http://2.bp.blogspot.com/_IJSFA7nl84U/SAV8oOwuubI/AAAAAAAAAPc/kklas9BZn8E/s320/MVC.png" border="0" alt="" /></a></div>
<p><span style="font-weight:bold;">Modelo</span></p>
<p>Muy bien continuando con el esquema de trabajo de <a href="http://www.blogger.com/www.rubyonrails.org/">Rails</a> y haciendo referencia al esquema anterior tenemos el primer elemento de nuestra metodología de programación la cual esta basada en <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete">CRUD</a> lo cual hace  a <span style="font-weight:bold;">Create, Read, Update y Delete</span> y ciertamente esta esta aplicada a las acciones básicas de una base de datos pero entonces que hay con esto, pues bueno una gran ventaja que nosotros obtenemos es el hecho de poder la base de datos con código de <a href="http://www.ruby-lang.org/es/">Ruby</a> y no por el clásico <a href="http://es.wikipedia.org/wiki/Celda_activa">SQL</a> y para lograr esto <a href="http://www.blogger.com/www.rubyonrails.org/">Rails</a> utiliza el <a href="http://es.wikipedia.org/wiki/Mapeo_objeto-relacional">ORM</a> el cual es <span style="font-weight:bold;">Object-Relational Mapping</span>, y eso quiere decir que la base de datos va a ser manipulada como un objeto y que a su vez esto lo vamos a poder realizar gracias a código de <a href="http://www.ruby-lang.org/es/">Ruby</a> que en su momento será traducido por el propio framework a código <a href="http://es.wikipedia.org/wiki/Celda_activa">SQL</a>, con lo cual ganamos una manipulación de la base de datos se hace de una forma mas intuitiva, no se preocupen lo veremos mas claramente en el siguiente <span style="font-weight:bold;">Post</span> cuando empecemos a desarrollar nuestro ejercicio.</p>
<p>Ahora bien la manipulación de <span style="font-weight:bold;">Vista</span> será en base a la combinación de codigo html + <a href="http://www.ruby-lang.org/es/">Ruby</a> de hecho actualmente hay una gran diferencia entre las extensiones de los archivos utilizados para las vistas entre <a href="http://www.blogger.com/www.rubyonrails.org/">Rails</a> 1.2 y <a href="http://www.blogger.com/www.rubyonrails.org/">Rails</a> 2.0 en el primero la extensión es .rhtml y en el segundo html.erb el cual hace referencia tanto a html como a <a href="http://www.ruby-lang.org/es/">Ruby</a>, recordemos que una gran ventaja de nuestra aplicación es el hecho de que con <a href="http://www.blogger.com/www.rubyonrails.org/">Rails</a> podemos integrar de forma directa las librerías mas importantes de <a href="http://es.wikipedia.org/wiki/JavaScript">Javascript</a> que son <a href="http://script.aculo.us/">Scriptaculos</a> y <a href="http://www.prototypejs.org/">Prototype</a>, pero recuerden es de suma importancia tener en cuenta que la lógica de esta aplicación la cual estará siendo afectada por el <span style="font-weight:bold;">Controlador</span> y en base a a esta suma obtenemos nuestro sistema de trabajo de <span style="font-weight:bold;">MVC</span>.</p>
<p><a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a> <span style="font-weight:bold;">Dont-Repeat-Yourself</span>, esta metodología de programación hace referencia al hecho de no repetir código y bueno mas haya de no repetir código es el hecho de reutilizar el codigo existente, en si esta tecnica hace referencia a la <a href="http://es.wikipedia.org/wiki/Programaci%C3%B3n_orientada_a_objetos">Programación Orientada a Objetos</a>, y es uno de los pilares de <a href="http://www.rubyonrails.org/">Ruby on Rails</a>.</p>
<p><a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST </a>Este punto merece un blog por si mismo, en la actualidad las paginas estaticas donde no existe la posiblidad de compartir información ya sea entre los mismo sitios o bien con aplicaciones de escritorio, estan perdiendo un gran punto de crecimiento y <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> es una técnica de arquitectura software para sistemas web que te permite comunicar por medio de <a href="http://es.wikipedia.org/wiki/C%C3%B3digo_HTML">HTTP</a> y la combinación con <a href="http://es.wikipedia.org/wiki/XML">XML</a>, ahora bien se define un conjunto pequeño de operaciones, las más importantes son <strong>POST</strong>, <strong>GET</strong>, <strong>PUT</strong> y <strong>DELETE</strong>. Con frecuencia estas operaciones se equiparan a las operaciones <a title="CRUD" href="http://es.wikipedia.org/wiki/CRUD">CRUD</a> que se requieren para la persistencia de datos, aunque POST no encaja exactamente en este esquema, en <a href="http://www.blogger.com/www.rubyonrails.org/">Rails</a> 2.0 veremos que ha tomado una importancía mayor asi como nos ha facilitado el hacer esta forma de arquitectura.</p>
<p><a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a> <strong>Desarrollo guiado por pruebas</strong>, o <strong>Test-driven development (TDD)</strong> es una práctica de <a title="Programación" href="http://es.wikipedia.org/wiki/Programaci%C3%B3n">programación</a> que involucra otras dos prácticas: <em>Escribir las pruebas primero (Test First Development)</em> y <em><a title="Refactorización" href="http://es.wikipedia.org/wiki/Refactorizaci%C3%B3n">Refactorización</a></em>. Para escribir las pruebas generalmente se utilizan las <a title="Prueba unitaria" href="http://es.wikipedia.org/wiki/Prueba_unitaria">pruebas unitarias</a>. Primeramente se escribe una prueba y se verifica que las pruebas fallen, luego se implementa el código que haga que la prueba pase satisfactoriamente y seguidamente se refactoriza el código escrito, ahora bien esto ya viene integrado con <a href="http://www.rubyonrails.org/">Ruby on Rails</a>, asi que esto nos permite tener un control sobre la calidad de nuestro software ma sin embargo en este Blog utilizaremos otra metodología no solo de pruebas de software sino de programación la cual es <a href="http://behaviour-driven.org/">BDD</a> y entrare en esta en detalle en un post siguiente.</p>
<p><span style="font-weight:bold;">NOTA: en Post siguientes realizaremos una aplicación de inicio a fin utilizando el codigo correcto.</span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[How to map irregular database tables with rails models]]></title>
<link>http://funonrails.wordpress.com/2009/10/21/how-to-map-irregular-database-tables-with-rails-models/</link>
<pubDate>Wed, 21 Oct 2009 12:53:16 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/10/21/how-to-map-irregular-database-tables-with-rails-models/</guid>
<description><![CDATA[Rails specifies standard conventions while creating models, controllers, migrations ( database table]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Rails specifies standard conventions while creating models, controllers, migrations ( database tables ).</p>
<p><strong>Conventions for creating database tables</strong></p>
<p>1. Table name should be plural</p>
<p>2. id field must be primary_key for table.</p>
<p>3. foreign_key  must be like &#60;model_name&#62;_id i.e. post_id, site_id</p>
<p><strong>Conventions for creating models &#38; Controllers</strong></p>
<p>1. Model name must be singular and controller name should be plural.</p>
<p>Although rails have some standard defined, sometimes it becomes quite necessary to map rails models with non- standard database tables.</p>
<p><strong>1. Table mapping</strong></p>
<p><code>class Review &#60; ActiveRecord::Base</p>
<p># Here comments is name of database table</p>
<p>set_table_name :comments</p>
<p>end</code></p>
<p><strong>2. Set primary key ( other than rails standar &#8216;id&#8217; primary_key )</strong></p>
<p><code>class Review &#60; ActiveRecord::Base</p>
<p># It assumes "reviews" as table in database</p>
<p># Below line indicates reviews table contains column_name "reviewId" which is a primary_key</p>
<p>set_primary_key :reviewId</p>
<p>end</code></p>
<p><strong>3. Foreign key association</strong></p>
<p><code>class Review &#60; ActiveRecord::Base</p>
<p># Below line indicates reviews table contains column_name 'RatingId' which is foreign_key to primary_key</p>
<p># of 'ratings' table.</p>
<p># It can be applied to any associan type [ has_one, has_many, belongs_to, has_many_through ]</p>
<p>belongs_to :rating, :class_name =&#62; "SiteUser", :foreign_key =&#62; "RatingId"</p>
<p>end</code></p>
<p><strong>4. Model association ( non-standard model name )</strong></p>
<p><code></p>
<p>class Review &#60; ActiveRecord::Base</p>
<p># Below line indicates reviews table contains column_name 'UserId' which is foreign_key to primary_key</p>
<p># of model with class_name 'SiteUser'</p>
<p>belongs_to :user, :class_name =&#62; 'SiteUser', :foreign_key: =&#62; 'UserId'</p>
<p>end</code></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[How to submit sitemap to search engines]]></title>
<link>http://funonrails.wordpress.com/2009/10/01/how-to-submit-sitemap-to-search-engines/</link>
<pubDate>Thu, 01 Oct 2009 11:57:11 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/10/01/how-to-submit-sitemap-to-search-engines/</guid>
<description><![CDATA[There are many ways that can be used to submit sitemap to search engines. Lets discuss approaches 1.]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><pre>There are many ways that can be used to submit sitemap to search engines.

Lets discuss approaches

1. Put sitemap.xml in public folder and you are done.
   Crawlers will find it through url

http://yourdomain.com/sitemap.xml

2. There are many online sites which generates sitemaps for you.
   like http://www.xml-sitemaps.com/
<pre>3. Open following urls in browser
   Be sure to add xml sitemap path for your site.
a. Google submit</pre>
<p>http://www.google.com/webmasters/tools/ping?sitemap=XML_SITEMAP_PATH</p>
<p>b. Yahoo Submit</p>
<pre>   http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=XML_SITEMAP_PATH</pre>
<p>c. Ask Submithttp://submissions.ask.com/ping?sitemap=XML_SITEMAP_PATH</p>
<p>d. Webmaster submit</p>
<pre>   http://webmaster.live.com/ping.aspx?siteMap=XML_SITEMAP_PATH</pre>
<p>5. Best practices in rails to submit sitemap is scheduled task (cron job)a. Write a rake task that will generate sitemap in rails public folder and</p>
<p>will submit sitemap.xml file to search engines. ( as mentioned above.)<br />
Got easy <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[--no-ri --no-rdoc for ruby gem installation]]></title>
<link>http://funonrails.wordpress.com/2009/09/30/no-ri-no-rdoc-for-ruby-gem-installation/</link>
<pubDate>Wed, 30 Sep 2009 12:27:22 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/09/30/no-ri-no-rdoc-for-ruby-gem-installation/</guid>
<description><![CDATA[One can install gem without rdoc using gem install GEM_NAME &#8211;no-ri &#8211;no-rdoc Skip ri rdoc]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>One can install gem without rdoc using</p>
<p>gem install GEM_NAME &#8211;no-ri &#8211;no-rdoc</p>
<p>Skip ri rdoc for all gem installation as i haven&#8217;t seen anyone using it.</p>
<p>Edit gemrc file<br />
Add following line to it<br />
<code>vi ~/.gemrc<br />
:gem: --no-ri --no-rdoc</code></p>
<p>Here is my ~/.vimrc file<br />
<code>---<br />
:verbose: true<br />
gem: --no-ri --no-rdoc<br />
:update_sources: true<br />
:sources:<br />
- http://gems.rubyforge.org<br />
- http://gems.github.com<br />
:backtrace: false<br />
:bulk_threshold: 1000<br />
:benchmark: false</code></p>
<p>That&#8217;s it !</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Managing multiple ruby versions and rails versions with rvm]]></title>
<link>http://funonrails.wordpress.com/2009/09/30/managing-multiple-ruby-versions-and-rails-versions-with-rvm/</link>
<pubDate>Wed, 30 Sep 2009 07:32:55 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/09/30/managing-multiple-ruby-versions-and-rails-versions-with-rvm/</guid>
<description><![CDATA[While working with many projects that uses different ruby versions and rails versions, one big probl]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>While working with many projects that uses different ruby versions and rails versions, one big problem arises that how do we manage all this ?</p>
<p>We know that managing multiple rails versions wont be problem at all.<br />
but what about ruby versions, How one can manage multiple ruby versions. also while upgrading or degrading ruby version, we need to install all gems again including rails.<br />
i know this is a big pain <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /><br />
How we can overcome this headache. meantime there must be some incompatibilities between two different ruby and rails versions.</p>
<p>Yesterday, i did some research and came to know that&#8230;</p>
<p>+ ruby 1.8.7 and rails 2.3.3 got quite stability and effectively. we can use it in next developments.<br />
+ Also, after installing ruby 1.9.1 and dependent gems for my project,<br />
and wondering that there are many incompatibilities while installing new gems with ruby 1.9.1</p>
<p>Some of the gems are mysql, ferret, acts_as_ferret, erubies, etc.</p>
<p>Today, while google, i found rvm gem and that seems very nice to manage multiple ruby versions.</p>
<p>Here are some steps explaining how to use it.</p>
<p># Install rvm gem to manage multiple ruby version<br />
# pre-requisite is that we already have ruby and rubygems installation<br />
<code>1. sudo gem install rvm</code></p>
<p># Install rvm for a particular user<br />
# It will also show how to use gem<br />
<code>2. rvm-install</code></p>
<p>3. Open new shell</p>
<p># Show all ruby, jruby installations<br />
<code>4. rvm list</code></p>
<p># Install ruby<br />
# specify ruby version<br />
<code>5. rvm install RUBY_VERSION_TO_BE_INSTALLED</code><br />
    (rvm install 1.9.1)</p>
<p># Install jruby<br />
# By default it will install jruby-1.3.1<br />
<code>6. rvm install jruby</code></p>
<p># Specify which ruby version to use ?<br />
# Note: Be sure that ruby version is installed<br />
<code>7. rvm use RUBY_VERSION_TO_USE </code><br />
    (rvm use 1.9.1)</p>
<p>#. Default i.e. version before rvm gem installation<br />
<code>8. rvm use default</code></p>
<p>Sounds, cool <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[jruby rails installation on ubuntu interpid]]></title>
<link>http://funonrails.wordpress.com/2009/09/29/jruby-rails-installation-on-ubuntu-interpid/</link>
<pubDate>Tue, 29 Sep 2009 10:22:16 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/09/29/jruby-rails-installation-on-ubuntu-interpid/</guid>
<description><![CDATA[# install mysql if you dont have already installed sudo apt-get install mysql-server mysql-client li]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p># install mysql if you dont have already installed<br />
sudo apt-get install mysql-server mysql-client libhtml-template-perl mailx dbishell libcompress-zlib-perl mysql-doc-5.0 tinyca</p>
<p># install ant and jdk<br />
sudo apt-get install ant sun-java6-jdk</p>
<p># install jruby<br />
mkdir software<br />
cd software<br />
wget http://dist.codehaus.org/jruby/jruby-bin-1.1.5.tar.gz<br />
tar xvfz jruby-bin-1.1.5.tar.gz<br />
ln -s jruby-1.1.5 jruby<br />
export PATH=$PATH:$HOME/software/jruby/bin</p>
<p># install the version of rails wanted by jruby<br />
jruby -S gem install jruby-openssl<br />
jruby -S gem install rails</p>
<p># list your gems<br />
jruby -S gem list</p>
<p># install the gems needed for db<br />
jruby -S gem install activerecord-jdbc-adapter activerecord-jdbcmysql-adapter</p>
<p># generate some code<br />
cd ~/scripts/ruby<br />
jruby -S rails wherehaveyoubeen -d mysql<br />
cd wherehaveyoubeen<br />
jruby script/generate controller states index</p>
<p># configure access to the database server<br />
vi config/database.yml</p>
<p>#development:<br />
#  adapter: jdbcmysql &#60;- very important!<br />
#  encoding: utf8<br />
#  database: test_development<br />
#  username: root<br />
#  password: database<br />
#  socket: /var/run/mysqld/mysqld.sock</p>
<p># generate the db<br />
jruby -S rake db:create:all<br />
jruby -S rake db:migrate</p>
<p># edit your app<br />
sudo apt-get install emacs ruby-elisp irb1.8 emacs22-el<br />
emacs -bg black -fg wheat app/views/states/index.html.erb</p>
<p># uncomment the secret in app/controllers/application.rb<br />
vi app/controllers/application.rb</p>
<p># run your app<br />
jruby script/server</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[upgrading rails version ]]></title>
<link>http://funonrails.wordpress.com/2009/09/29/upgrading-rails-version/</link>
<pubDate>Tue, 29 Sep 2009 08:12:21 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/09/29/upgrading-rails-version/</guid>
<description><![CDATA[Here are the simple steps to be followed while upgrading rails version to use. # Install rails versi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Here are the simple steps to be followed while upgrading rails version to use.</p>
<p># Install rails version<br />
1. gem install rails -v<br />
    == gem install rails 2.3.3</p>
<p># Upgrade environment.rb for new version<br />
2. RAILS_GEM_VERSION = &#8221; unless defined? RAILS_GEM_VERSION<br />
    == RAILS_GEM_VERSION = &#8216;2.3.3&#8242; unless defined? RAILS_GEM_VERSION</p>
<p># Upgrade necessary files for the new version<br />
3. rake rails:upadte</p>
<p># Start server<br />
4. /script/server</p>
<p>Thats, it !</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[4 steps to install nginx with passenger]]></title>
<link>http://funonrails.wordpress.com/2009/09/09/4-steps-to-install-nginx-with-passenger/</link>
<pubDate>Wed, 09 Sep 2009 12:47:15 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/09/09/4-steps-to-install-nginx-with-passenger/</guid>
<description><![CDATA[Install passenger program that will run your rails application 1. sudo gem install passenger Install]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Install passenger program that will run your rails application<br />
<strong>1. sudo gem install passenger</strong><br />
Install nginx server with passenger enabled<br />
<strong>2. passenger-install-nginx-module</strong></p>
<p>it will open apt, click &#8220;Enter&#8221; to contine<br />
then select option 1 for default install<br />
then it will ask<br />
Where do you want to install Nginx to?</p>
<p>Please specify a prefix directory [/opt/nginx]:<br />
press enter</p>
<p>then copy following block</p>
<p><strong> server {<br />
listen 80;<br />
server_name <a href="http://www.yourhost.com/" target="_blank">www.yourhost.com</a>;<br />
root /somewhere/public;   # &#60;&#8212; be sure to point to &#8216;public&#8217;!<br />
passenger_enabled on;<br />
}</strong></p>
<p>Make nginx Configuration<br />
3. vi /opt/nginx/conf/nginx.conf<br />
Make passenger_root and passenger_ruby path to configuration<br />
<strong></p>
<p>http {<br />
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.4;<br />
passenger_ruby /usr/local/bin/ruby;<br />
</strong></p>
<p>then add server configuration block inside http block<br />
http{<br />
&#8230;<br />
<strong> server {<br />
listen 80;<br />
server_name <a href="http://www.yourhost.com/" target="_blank">www.yourhost.com</a>; //Make sure this dns entry inside /etc/hosts<br />
root /carsonline/public;   # &#60;&#8212; be sure to point to &#8216;public&#8217;! //here carsonline is RAILS_ROOT<br />
passenger_enabled on;<br />
}</strong></p>
<p>Thats, all</p>
<p>4. Launch Server</p>
<p>/opt/nginx/sbin/nginx</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[How do i generate SEO sitemap in rails ?]]></title>
<link>http://funonrails.wordpress.com/2009/09/09/how-do-i-generate-seo-sitemap-in-rails/</link>
<pubDate>Wed, 09 Sep 2009 10:44:55 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/09/09/how-do-i-generate-seo-sitemap-in-rails/</guid>
<description><![CDATA[What is sitemap ? Sitemap is nothing but a .xml file containing urls available on your site It conta]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>What is sitemap ? </strong></p>
<p>Sitemap is nothing but a .xml file containing urls available on your site</p>
<p>It contains URL, last modified date, frequency of content change and priority ( between 0..1 )</p>
<p><strong>Why we need sitemap ? </strong></p>
<p>We can submit sitemap file to search engine. It will help them in analysing what urls on your site are available for crawling.</p>
<p><strong>What is xml pattern ? </strong></p>
<pre>   &#60;?xml version="1.0" encoding="UTF-8"?&#62;
      &#60;urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"&#62;

        &#60;url&#62;
           &#60;loc&#62;http://www.example.com/&#60;/loc&#62;
           &#60;lastmod&#62;2005-01-01&#60;/lastmod&#62;
           &#60;changefreq&#62;monthly&#60;/changefreq&#62;
           &#60;priority&#62;0.8&#60;/priority&#62;
        &#60;/url&#62;
       ...
       ...
    &#60;/urlset&#62;</pre>
<p><strong> What will be the path for sitemap ? </strong></p>
<p>&#8220;www.example.com/sitemap.xml&#8221;</p>
<p><strong>Are we going to generate sitemap manually ? </strong></p>
<p>No&#8230; there is mephisto sitemap plugin.We can use it.</p>
<p>script/plugin install  http://svn.appelsiini.net/svn/rails/plugins/mephisto_sitemap/</p>
<p><strong>Am i needed to generate to sitemap for each request ? </strong></p>
<p>No &#8230;&#8230;&#8230;..we can generate it in background task daily basis.</p>
<p><strong>How it will be accessed for request to sitemap ? </strong></p>
<p>we can define path to local file in routes.</p>
<p>map.connect &#8220;sitemap.xml&#8221;, :controller =&#62; :sitemap</p>
<p>Class SitemapController</p>
<p>def index</p>
<p>render &#8220;some local file path&#8221;</p>
<p>end</p>
<p>&#8230;.</p>
<p><strong>Here are the reference links </strong></p>
<p>http://www.fortytwo.gr/blog/19/Generating-Sitemaps-With-Rails</p>
<p>http://www.bestechvideos.com/2008/07/04/ruby-plus-71-how-to-create-a-seo-sitemap-for-rails-apps</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Snow LeopardでRuby On Rails環境構築]]></title>
<link>http://footmark.wordpress.com/2009/09/08/snow-leopard%e3%81%a7ruby-on-rails%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89/</link>
<pubDate>Tue, 08 Sep 2009 03:14:12 +0000</pubDate>
<dc:creator>Dongri Jin</dc:creator>
<guid>http://footmark.wordpress.com/2009/09/08/snow-leopard%e3%81%a7ruby-on-rails%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89/</guid>
<description><![CDATA[　　 　 　 1. Snow Leopardでのデフォルト環境確認 $ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin1]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><img class="alignnone size-full wp-image-590" title="snowleopard" src="http://footmark.wordpress.com/files/2009/09/snowleopard.png" alt="snowleopard" width="159" height="166" /> 　　<img class="alignnone size-full wp-image-591" title="rails" src="http://footmark.wordpress.com/files/2009/09/rails.png" alt="rails" width="132" height="168" /><br />
　<br />
　<br />
<strong>1. Snow Leopardでのデフォルト環境確認</strong></p>
<pre>$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
$ gem -v
1.3.1
$ rails -v
Rails 2.2.2</pre>
<p>　<br />
<strong>2. mysql インストール</strong></p>
<p>http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg こちらから Mac OS X 10.5 (x86_64) をダウンロード。ディスクイメージを開いたら、デフォルトのオプションのまま、まず「mysql-5.1.38-osx10.5-x86_64.pkg」をインストール。次に、同じくデフォルトオプションのまま「MySQLStartupItem.pkg」をインストールし、さらに「MySQL.prefPane」をダブルクリック<br />
　<br />
<strong>3. mysql 操作</strong></p>
<pre>$ /usr/local/mysql/bin/mysql -u root -p
Enter password:</pre>
<div>データベース作成：</div>
<pre>mysql&#62; create database mysqldemo default character set utf8;</pre>
<div>ユーザー作成、権限付与：</div>
<pre>mysql&#62; grant all privileges on mysqldemo.* to
    testuser@localhost identified by 'password';</pre>
<p>　<br />
<strong>4. gem install mysql</strong></p>
<pre>$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql --
   --with-mysql-config=/usr/local/mysql/bin/mysql_config</pre>
<p><font color="red">(以下のエラーが発生した場合はXcodeをインストールしてください)</font></p>
<div style="font-size:x-small;">
Building native extensions. This could take a while…<br />
ERROR: Error installing mysql:<br />
ERROR: Failed to build gem native extension.</p>
<p>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config<br />
mkmf.rb can’t find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h</p>
<p>Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.<br />
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
</p></div>
<p>　<br />
<strong>5. rails プロジェクト作成</strong></p>
<pre>$ rails -d mysql mysqldemo</pre>
<p>database.yml ファイル編集</p>
<pre>development:
    adapter: mysql
    encoding: utf8
    database: mysqldemo
    pool: 5
    username: testuser
    password: password
    socket: /tmp/mysql.sock</pre>
<p>　<br />
<strong>6. scaffold 作成</strong></p>
<pre>$ script/generate scaffold user email:string name:string age:integer
$ rake db:migrate</pre>
<p>　<br />
<strong>7. サーバー起動して確認</strong></p>
<pre>$ script/server</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[DOT.NET/PHP developer - Central London - Upto £35k]]></title>
<link>http://calvinjnr.wordpress.com/2009/09/07/dot-netphp-developer-central-london-upto-35k/</link>
<pubDate>Mon, 07 Sep 2009 10:00:21 +0000</pubDate>
<dc:creator>calvinjnr</dc:creator>
<guid>http://calvinjnr.wordpress.com/2009/09/07/dot-netphp-developer-central-london-upto-35k/</guid>
<description><![CDATA[Leading creative digital agency in London are looking for a junior/mid weight back-end developer. Th]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Leading creative digital agency in London are looking for a junior/mid weight back-end developer. The essence for this role is a good split between PHP and DOT.NET.</p>
<p>Knowledge in the following ========================<br />
* ASP.NET 2.0 &#38; 3.5 (C#)<br />
* PHP 5<br />
* Visual Studio 2008<br />
* Object-Oriented Programming<br />
* SQL Server<br />
* MySql<br />
* Web site security concepts<br />
* XML<br />
* XSLT</p>
<p>Professional Programming Practices such as version control (VSS, Subversion, CVS etc).</p>
<p>Skills in the following will be merited (in no particular order)<br />
========================== ===========</p>
<p>* Agency experience<br />
* Fluorine/AMF<br />
* CMS Systems<br />
* Winforms .net<br />
* Flash &#8211; underlying concepts<br />
* Actionscript<br />
* Javascript<br />
* XHTML/CSS<br />
* Disability Discrimination Act (DDA)<br />
* VB.net<br />
* Java<br />
* RubyOnRails<br />
* Experience with other databases<br />
* Knowledge of various PHP frameworks<br />
* Experience in building Social Networking Apps<br />
You have a degree in Computer Science (or equivalent experience) and an understanding and passion of web based software systems and the designing of those systems. You also strive to gain extensive experience in the architecture of large object oriented software projects. You are a skilled programmer who can work independently and yet you have the ability to motivate people and assert your ideas. You will be part of a team and you will have an imperative role in the opening stages of each project.</p>
<p>They want you to be:<br />
Passionate about the Internet<br />
Quality focused in every detail<br />
Precise<br />
Professional<br />
Independent<br />
Communicative<br />
Problem Solver</p>
<p>Excellent opportunity to progress your career for this very creative digital agency.</p>
<p> <a href="mailto:neil@majorplayers.co.uk">neil@majorplayers.co.uk</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Multiple sites hosting using radiant cms]]></title>
<link>http://funonrails.wordpress.com/2009/09/03/multiple-sites-hosting-using-radiant-cms/</link>
<pubDate>Thu, 03 Sep 2009 15:19:45 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/09/03/multiple-sites-hosting-using-radiant-cms/</guid>
<description><![CDATA[There are almost 4 to 5 simple steps you need to followed before getting multiple sites working usin]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>There are almost 4 to 5 simple steps you need to followed before getting multiple sites working using radiant cms</p>
<p>1. Setup radiant cms </p>
<p>first Install radiant gem<br />
<code>sudo gem install radiant</code></p>
<p>set &#8216;radiant&#8217; under path<br />
<code>export PATH=$PATH:/var/lib/gems/1.8/gems/radiant-0.8.0/bin</code></p>
<p>Now, we have done with radiant installation.</p>
<p>Let&#8217;s create new project..</p>
<p><code>$ radiant multisite -d mysql</code><br />
<code>$ cd multisite/</code></p>
<p>Edit database.yml</p>
<p><code><br />
$ vi config/database.yml<br />
development:<br />
  adapter: mysql<br />
  database: multisite_development<br />
  username: root<br />
  password: abcd<br />
  host: localhost</code></p>
<p>Migrations</p>
<p><code>rake db:create</code></p>
<p># Run the database bootstrap rake task:<br />
<code><br />
 rake db:bootstrap<br />
This task will destroy any data in the database. Are you sure you want to<br />
continue? [yn] yes<br />
...<br />
Create the admin user (press enter for defaults).<br />
Name (Administrator): admin<br />
Username (admin): admin<br />
Password (radiant):<br />
....<br />
Select a database template:<br />
1. Empty<br />
2. Roasters (a coffee-themed blog or brochure)<br />
3. Simple Blog<br />
4. Styled Blog<br />
[1-4]: 2<br />
....<br />
</code></p>
<p>Now we are ready to start</p>
<p><code>script/server</code></p>
<p>Open browser<br />
<code>http://localhost:3000</code></p>
<p>We will see your site up</p>
<p>To manage site</p>
<p><code>http://localhost:3000/admin</code></p>
<p>Now Lets start with multiple sites management<br />
1) Clone multi_site extension into vendor/extensions of your project.<br />
<code>cd vendor/extensions/<br />
git clone git://github.com/zapnap/radiant-multi-site-extension.git multi_site</code><br />
2) Run the extension migrations.</p>
<p><code>  rake db:migrate:extensions</code></p>
<p>3) Run the extension update task.<br />
<code><br />
  rake radiant:extensions:multi_site:update</code></p>
<p>4) Restart your server</p>
<p>And we are done with multisite installation</p>
<p>Open</p>
<p>http://localhost:3000/admin/sites</p>
<p>Add multiple sites as you wanted<br />
Name                Domain pattern              Base domain name<br />
====                ==============        ================<br />
site 1                  sandip                                 sandip<br />
site 2                  gautam                                gautam</p>
<p>Dont forget to make dns entries<br />
vi /etc/hosts<br />
<code><br />
127.0.0.1 localhost<br />
...<br />
127.0.0.1 sandip<br />
127.0.0.1 gautam</code></p>
<p>One more, by deault pages created for new sites added are not published.<br />
Please be sure to make them published and modify contents to identify them</p>
<p>Now you can view different sites.</p>
<p>http://sandip:3000</p>
<p>http://gautam:3000</p>
<p>Thats, All</p>
<p>Cheers !</p>
<p>$@ndip</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[What is new in edge rails 2.3.3  ?]]></title>
<link>http://funonrails.wordpress.com/2009/09/02/what-is-new-in-edge-rails-2-3-3/</link>
<pubDate>Wed, 02 Sep 2009 12:24:26 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/09/02/what-is-new-in-edge-rails-2-3-3/</guid>
<description><![CDATA[Rails community has released rails 2.3.3 recently with major upgrades and several bug fixes added. O]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Rails community has released rails 2.3.3 recently with major upgrades and several bug fixes added.</p>
<p>On the other side, Rails 3 ( i.e. merge of rails and merb framework ) is supposed to be officially get released in this May.</p>
<p>Lets see what are the notable features added in rails 2.3.3</p>
<p><strong>1. Rack</strong><br />
<em><br />
What is this rack ?</em><br />
Abstraction built on the top of rails framework</p>
<p><em>What it does ?</em><br />
It provides minimal interface between webservers supporting ruby ( like  apache-mongrel, nginx-passenger ) and rails framework.<br />
Gives access to middleware goodness<br />
i.e. wrapping HTML requests and response in simple way<br />
unifies and distills the API for web servers, web frameworks, and software in between</p>
<p><a href="http://guides.rubyonrails.org/rails_on_rack.html" target="_blank">read more &#8230;</a></p>
<p><strong>2. Metal</strong><br />
It is a subset of rack middleware specially designed to integrate with rails    application.</p>
<p><em>Why to use it ?</em><br />
Whenever you need achieve raw speed for certain requests by skipping action controller stack.<br />
<a href="http://weblog.rubyonrails.org/2008/12/17/introducing-rails-metal" target="_blank"> read more &#8230;</a></p>
<p><strong>3. Engines</strong><br />
It was a plugin that got merged in rails core.<br />
It is used for sharing controllers, models and views seamlessly from within a plugin to your rails application.<br />
<a href="http://rails-engines.org/news/2009/02/02/engines-in-rails-2-3/" target="_blank"> read more &#8230;</a></p>
<p><strong>4. Templates</strong><br />
These are the ruby files which describes which gems, plugins and initiliazers  has to be added while creating new rails project.<br />
<a href="http://railscasts.com/episodes/148-app-templates-in-rails-2-3" target="_blank"> read more &#8230;</a></p>
<p><strong>5. Nested Forms</strong><br />
Earlier nested forms for has_one and has_many associations wasn&#8217;t<br />
there in rails.<br />
this release added nested forms complex associations in models.<br />
<a href="http://weblog.rubyonrails.org/2009/1/26/nested-model-forms" target="_blank"> read more &#8230;</a> <a href="http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes" target="_blank">also see &#8230;</a></p>
<p><strong>One of good rails architecture diagram found while google<br />
</strong></p>
<div class="wp-caption alignnone" style="width: 470px"><a href="http://cleanair.highgroove.com/articles/2009/04/21/rails-marketecture-diagram"><img title="Rails 2.3 architecture diagram" src="http://img.skitch.com/20090422-gts8sseg1k8rgiafi1d7e54px6.png" alt="Rails 2.3 architecture diagram" width="460" /></a><p class="wp-caption-text">Rails 2.3 architecture diagram</p></div>
<p><strong>Edge rails Installation</strong><br />
gem install rails &#8211;source <a href="http://gems.rubyonrails.org" target="_blank">http://gems.rubyonrails.org</a></p>
<p>Thanks to rails community  for bringing this things in rails core.<br />
Cheers, now rails is getting its way !</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Rodrigo going insane!]]></title>
<link>http://spreadinglogic.wordpress.com/2009/08/25/rodrigo-going-insane/</link>
<pubDate>Tue, 25 Aug 2009 13:06:12 +0000</pubDate>
<dc:creator>Rodrigo Alves</dc:creator>
<guid>http://spreadinglogic.wordpress.com/2009/08/25/rodrigo-going-insane/</guid>
<description><![CDATA[Quem  já sabe quem sou eu, lê esse blog e vê meus tweets,  talvez saibam que eu sou Pernambucano, is]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Quem  já sabe quem sou eu, lê esse blog e vê <a href="http://twitter.com/r_a_v" target="_blank">meus tweets</a>,  talvez saibam que eu sou Pernambucano, isso pra mim é muitas vezes irritante pois não existe uma comunidade ou grupo de desenvolvimento Ruby(Ou qualquer outra coisa). Dizem que o Brasil está quase sempre 2 anos atrás dos States e parece que Pernambuco tá 2 anos atrás do Brasil <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  . Mas ontem a coisa foi diferente, eu nunca tinha visitado uma Universidade até então, só que eu tive a oportunidade de conhecer um amigo de lá, ele cursa Ciência da Computação, a Universidade é a <a href="http://www.ufrpe.br/" target="_blank">Federal Rural de Pernambuc</a>o. Quando eu disse que nunca tinha visitado uma faculdade não foi bem assim, eu tinha ido à uma particular chamada Maurício de Nassau, mas me decepcionei, só vi filhindo-de-papai motherfucker, a alta burguesia recifence em versão pré-adulta, foi péssimo, um dia eu li <a href="http://akitaonrails.com/2009/04/17/off-topic-devo-fazer-faculdade" target="_blank">um post </a>do Fábio Akita que descreveu tudo o que eu senti naquele dia. Mas ontem foi mágico nunca pensei que algo público pudesse ser tão bom (Finalmente algo pra poder elogiar no Brasil) me parece que as Federais são o inverso total do Ensino Básico brasileiro, totally amazing!</p>
<h2 style="text-align:center;"><strong>Pulando pra parte mais legal já que é impossível descrever tudo&#8230;</strong></h2>
<p>Eu assisti uma noite de aula inteira de puro aprendizado, uma turma muito centrada e ao mesmo tempo descontraída, o professor era muito bom. A gente viu sobre princípios básicos da Computação, loops, matemática básica: Funções polinomiais, matrizes, cofatores, álgebra linear, álgebra booleana, além de um pouco de Teoria da Computação. Infelizmente eu não posso ir sempre, e só de pensar que eu ainda tô no 2° ano do médio&#8230; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> .  As próximas aulas já vai ter a introdução à programação, linguagens (Eles começam com C e Python). Tinha um cara lá muito maluco de 2 metros de altura que escrevia C++ como Shakespeare escrevia romances (é, eu sei&#8230; C++&#8230;) Esse cara me ensinou &#8211; quase &#8211; tudo que eu ainda não sabia sobre o funcionamento de uma CPU, ele me deu um<em> insight</em> indescritível. Lá eu vi, que, pelo menos por enquanto a coisa não é pra Web, esse cara que eu falei antes mal sabe HTML. A primeira professora falou sobre matemática básica e tals , mas as sulas seguintes foram com um Professor chamado Rodrigo (Coincidência?) o cara era muito louco e muito bom professor, ninguém se surpreenderia se ele começasse a explicar Processamento de Gráficos em francês.</p>
<h2 style="text-align:center;"><strong>E agora&#8230;</strong></h2>
<p>A estrutura lá é mesmo excepcional, PCs com Ubuntu e XP e internet WIFI de alta velocidade, postei até um<a href="http://twitter.com/r_a_v/statuses/3520538499" target="_blank"> tweet </a>enquanto estava lá, no Ubuntu andei fuçando alguns docs e colei 2 no Google Docs. Seriam das próximas aulas:</p>
<p><a href="http://docs.google.com/present/edit?id=0AWh5eLo_GafCZGhydnpnOTRfMTI5OHdkOGZmag&#38;hl=en" target="_blank">Link pra um&#8230;</a><br />
<a href="http://docs.google.com/present/edit?id=0AWh5eLo_GafCZGhydnpnOTRfNDdjcTZ6c3A4Mg&#38;hl=en" target="_blank"> Link pra o outro&#8230;</a></p>
<p>Foi mal pessoal não consegui colocar o embed no WordPress.</p>
<h2 style="text-align:center;"><strong>Evangelizando&#8230;</strong></h2>
<p>Como não poderia deixar de ser, eu vi a galera escrevendo C++ e tals e resolvi cutucar. Dei uma  &#8217;aula&#8217;  breve sobre o que eu sei de Ruby &#8211; expliquei a origem e história da linguagem, mostrei a semelhança com Python e Perl, mostrei as gems. Tudo isso sem contar que o Ubuntu ainda não tava com nada de ruby instalado, rodei um sudo apt-get intall ruby1.8.7 depois sudo apt-get install irb e gems, sqlib, etc.. Tudo isso em uma aula! Mostei aos caras o que se pode fazer com Ruby, cheguei a instalar o Rails mas não deu tempo de demonstrar, ainda falei sobre git e os caras ficaram babando, eles só conheciam svn e ficaram impressionados tbm com a praticidade e usabilidade do Github. Pena que não deu pra mostrar Rails, só queria mostrar o scaffolding <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  , pelo menos eles viram como o Ruby é lindo.</p>
<p>Como se não bastasse tudo isso, a galera foi super receptiva comigo e ficou de olho num espinhento de 15 anos, eles gostaram bastante e eu mais ainda. Os caras ficaram abismados pelo fato de eu ser mega-autodidata teve até um lá que perguntou se eu era autista, hiper-ativo ou coisa parecida, QI elevado, wtf? Atacaram a minha vaidade hehe. Pra terminar, conheci altas gatas <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  uma mais linda que a outra, como é pode?!</p>
<p>Valeu galera, valeu Ruby, valeu UFRPE!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby On Rails Search Engine Optimization (SEO)]]></title>
<link>http://funonrails.wordpress.com/2009/08/17/ruby-on-rails-search-engine-optimization-seo-techniques/</link>
<pubDate>Mon, 17 Aug 2009 10:46:24 +0000</pubDate>
<dc:creator>sandipransing</dc:creator>
<guid>http://funonrails.wordpress.com/2009/08/17/ruby-on-rails-search-engine-optimization-seo-techniques/</guid>
<description><![CDATA[Search Engines ( like google, yahoo ) mainly uses crawlers for returning results. Crawler is the pro]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Search Engines ( like google, yahoo ) mainly uses <strong>crawlers</strong> for returning results.</p>
<p><strong>Crawler</strong> is the program which searches world wide web ( www ) and returns ranked pages.</p>
<p>Lets see what are the search engine optimization (SEO) techniques we can adopt so that your rails<br />
website pages will appear in search results.</p>
<p><strong>1. Title Of Page</strong></p>
<p><strong>2. Meta tags</strong></p>
<p><strong>3. Page URL</strong></p>
<p><strong>4. Page Contents</strong> ( this includes anchors to other pages, headers, image titles and alt texts when image not found then normal texts )</p>
<p>We can easily skip some pages from search by mentioning them in robots.txt which is by default should be in application root.</p>
<p>And Ofcourse, we can manage all this in rails very easily..</p>
<p>How ????</p>
<p>We can have in rails</p>
<p><strong>1. Dynamic page titles,</strong></p>
<p><strong>2. Meta tags and</strong></p>
<p><strong>3. Sexy perma URLs in rails</strong></p>
<p><strong>4. Also, we can define some standard on page content development.</strong></p>
<p>&#8230;got Easy &#8230;&#8230;, Cheers !</p>
<p>$@ndip</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[search &amp; will_paginate (ruby on rails)le      ]]></title>
<link>http://utcl95.wordpress.com/2009/08/14/search-will_paginate-ruby-on-rails/</link>
<pubDate>Fri, 14 Aug 2009 02:49:13 +0000</pubDate>
<dc:creator>utcl95</dc:creator>
<guid>http://utcl95.wordpress.com/2009/08/14/search-will_paginate-ruby-on-rails/</guid>
<description><![CDATA[Deseaba poner una busqueda a una pequena app en rails, asi llegue al tutorial: Simple Search de ahi ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Deseaba poner una busqueda  a una pequena app en rails, asi llegue al tutorial:<br />
<a href="http://wiki.github.com/mislav/will_paginate/simple-search"><strong>Simple Search</strong></a> de ahi al <a href="http://railscasts.com/episodes/51-will-paginate"><strong>screencas</strong>t</a>, pero nada, no funcionaba, a buscar algun tutorial y nada, mare, ajo, erda, mai&#8230; Asi q ha usar el metodo &#8220;por tonteo y error&#8221;.</p>
<p><strong>Primero:</strong><br />
<code>$ ruby script/generate scaffold supplier code:string name:string</code></p>
<p><strong>Archivos a modificar :</strong><br />
app/model/suppier.rb<br />
app/controllers/suppliers_controller.rb<br />
app/views/suppliers/index.html.erb</p>
<p><strong>1. Insertar un text_field para busqueda:</strong><br />
file: app/views/suppliers/index.html.erb<br />
<code><br />
&#60;h1&#62;Listing suppliers&#60;/h1&#62;<br />
&#60;% form_tag request.path, :method =&#62; 'get' do  %&#62;<br />
  &#60;% content_tag :label do %&#62;<br />
    Search:<br />
    &#60;%= text_field_tag :search, params[:search] %&#62;<br />
  &#60;% end %&#62;<br />
&#60;% end %&#62;<br />
</code></p>
<p><strong>2. En el modelo, la parte de busqueda</strong><br />
file: app/model/suppier.rb</p>
<p>class Supplier &#60; ActiveRecord::Base<br />
def self.search(search, page)<br />
Supplier.paginate :page =&#62; page, :per_page =&#62; 5, :conditions=&#62;['name like ?', search], &#58;order =&#62; &#8216;code desc&#8217;<br />
end<br />
end</p>
<p><strong>3. Y finalmente, el controlador</strong><br />
file: app/controllers/suppliers_controller.rb<br />
<code><br />
def index<br />
@search = '%' + params[:search] + '%'<br />
@suppliers = Supplier.search(@search, params[:page])</code></p>
<p>respond_to do &#124;format&#124;<br />
format.html # index.html.erb<br />
format.xml  { render &#58;xml =&#62; @suppliers }<br />
end<br />
end<br />
</code></p>
<p>Y ya ta... bueno para la proxima le doy formato al codigo... uff</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[alias_method_chain em Models]]></title>
<link>http://spreadinglogic.wordpress.com/2009/08/05/alias_method_chain-em-models/</link>
<pubDate>Wed, 05 Aug 2009 14:47:35 +0000</pubDate>
<dc:creator>Rodrigo Alves</dc:creator>
<guid>http://spreadinglogic.wordpress.com/2009/08/05/alias_method_chain-em-models/</guid>
<description><![CDATA[Esse artigo é uma tradução do Post original do Yehuda katz Como as pessoas sabem, tem ocorrido um ce]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Esse artigo é uma tradução do <a href="http://yehudakatz.com/2009/03/06/alias_method_chain-in-models/" target="_blank">Post original</a> do Yehuda katz</p>
<p>Como as pessoas sabem, tem ocorrido um certo vai-e-vem entre mim, o aparente inimigo do alias_method_chain, e as pessoas que vêm alias_method_chain como uma API extremamente razoável.</p>
<p>Existem basicamente 2 formas para usar o alias_method_chain:</p>
<p>#Organizar Código Interno<br />
#Modificar Código que já Existe</p>
<p>Usar o alias_method_chain para organizar código interno é uma discussão interesssante que Eu espero continuar no futuro.  Hoje Eu quero direcionar o seu uso para substituir métodos no ActionController::Base e no ActiveRecord::Base. Pessoas que fazem isso estão cegamente usando a técnica que tem sido mais evangelizada como solução para todos os seus problemas quando Ruby vem com uma solução perfeitamente boa.</p>
<p>Considere esse post do <a href="http://www.vaporbase.com/postings/alias_method_chain_in_a_module" target="_blank">vaporbase</a>, que Eu definitivamente não estou usando. Isso representa uma forma comum que as pessoas estão tentando usar em Rails.</p>
<p><strong>Primeiro, o uso em um Model:</strong></p>
<pre style="width:auto;clear:none;font-size:12px;line-height:1.333;white-space:pre;font-family:monospace;margin:0;"><span style="color:#9966cc;font-weight:bold;">class</span> Foo <span style="color:#006600;font-weight:bold;">&#60;</span> <span style="color:#6666ff;font-weight:bold;">ActiveRecord::Base</span>
  <span style="color:#9966cc;font-weight:bold;">include</span> FooBar
<span style="color:#9966cc;font-weight:bold;">end</span></pre>
<p><strong>Segundo, a implementação no código:</strong></p>
<pre style="width:auto;clear:none;font-size:12px;line-height:1.333;white-space:pre;font-family:monospace;margin:0;"><span style="color:#9966cc;font-weight:bold;">module</span> FooBar
  <span style="color:#9966cc;font-weight:bold;">module</span> ClassMethods
    <span style="color:#9966cc;font-weight:bold;">def</span> find_with_bar<span style="color:#006600;font-weight:bold;">(</span> <span style="color:#006600;font-weight:bold;">*</span>args <span style="color:#006600;font-weight:bold;">)</span>
      find_without_bar<span style="color:#006600;font-weight:bold;">(</span> <span style="color:#006600;font-weight:bold;">*</span>args <span style="color:#006600;font-weight:bold;">)</span>
      <span style="color:#008000;font-style:italic;">#...or whatever </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;">def</span> <span style="color:#0000ff;font-weight:bold;">self</span>.<span style="color:#9900cc;">included</span><span style="color:#006600;font-weight:bold;">(</span>base<span style="color:#006600;font-weight:bold;">)</span>
    base.<span style="color:#9900cc;">class_eval</span> <span style="color:#9966cc;font-weight:bold;">do</span>
      extend ClassMethods
      <span style="color:#9966cc;font-weight:bold;">class</span> <span style="color:#006600;font-weight:bold;">&#60;&#60;</span> <span style="color:#0000ff;font-weight:bold;">self</span>
        alias_method_chain <span style="color:#ff3333;font-weight:bold;">:find</span>, <span style="color:#ff3333;font-weight:bold;">:bar</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>
<span style="color:#9966cc;font-weight:bold;">end</span></pre>
<pre style="width:auto;clear:none;font-size:12px;line-height:1.333;white-space:pre;font-family:monospace;margin:0;"><span style="color:#9966cc;"><strong>
</strong></span></pre>
<p><strong>Isso equivale a:</strong></p>
<pre style="width:auto;clear:none;font-size:12px;line-height:1.333;white-space:pre;font-family:monospace;margin:0;"><span style="color:#9966cc;font-weight:bold;">module</span> FooBar
  <span style="color:#9966cc;font-weight:bold;">def</span> <span style="color:#0000ff;font-weight:bold;">self</span>.<span style="color:#9900cc;">included</span><span style="color:#006600;font-weight:bold;">(</span>base<span style="color:#006600;font-weight:bold;">)</span>
    base.<span style="color:#9900cc;">extend</span><span style="color:#006600;font-weight:bold;">(</span>ClassMethods<span style="color:#006600;font-weight:bold;">)</span>
  <span style="color:#9966cc;font-weight:bold;">end</span>

  <span style="color:#9966cc;font-weight:bold;">module</span> ClassMethods
    <span style="color:#9966cc;font-weight:bold;">def</span> find<span style="color:#006600;font-weight:bold;">(</span><span style="color:#006600;font-weight:bold;">*</span>args<span style="color:#006600;font-weight:bold;">)</span>
      <span style="color:#9966cc;font-weight:bold;">super</span>
      <span style="color:#008000;font-style:italic;">#...or whatever</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>
<p>Assim tá certo, se você está procurando modificar subclasses do ActiveRecord::Base ou ActionController::Base. Lembre-se que você está numa linguagem de programação orientada a objeto com herança.</p>
<p>Se você quiser modificar todos os models em sua aplicação, crie sua própria subclasse no ActiveRecord::Base , e &#8220;here&#8221; isso através da sua aplicação.</p>
<h3>Outro exemplo</h3>
<p>Um <a href="http://nex-3.com/posts/42-overriding-find-for-cleaner-code" target="_blank">outro exemplo</a>, de uma pessoa muito inteligente foi ainda mais longe.</p>
<p><strong>Ele começou com:</strong></p>
<pre style="width:auto;clear:none;font-size:12px;line-height:1.333;white-space:pre;font-family:monospace;margin:0;"><span style="color:#9966cc;font-weight:bold;">class</span> Post <span style="color:#006600;font-weight:bold;">&#60;</span> <span style="color:#6666ff;font-weight:bold;">ActiveRecord::Base</span>
  <span style="color:#9966cc;font-weight:bold;">class</span> <span style="color:#006600;font-weight:bold;">&#60;&#60;</span> <span style="color:#0000ff;font-weight:bold;">self</span>
    <span style="color:#9966cc;font-weight:bold;">def</span> find_with_tags<span style="color:#006600;font-weight:bold;">(</span><span style="color:#006600;font-weight:bold;">*</span>args<span style="color:#006600;font-weight:bold;">)</span>
      options = extract_options_from_args!<span style="color:#006600;font-weight:bold;">(</span>args<span style="color:#006600;font-weight:bold;">)</span>
      <span style="color:#9966cc;font-weight:bold;">if</span> tag = options.<span style="color:#9900cc;">delete</span><span style="color:#006600;font-weight:bold;">(</span><span style="color:#ff3333;font-weight:bold;">:tags</span><span style="color:#006600;font-weight:bold;">)</span>
        options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:select</span><span style="color:#006600;font-weight:bold;">]</span> <span style="color:#006600;font-weight:bold;">&#124;&#124;</span>= <span style="color:#996600;">'posts.*'</span>
        options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:joins</span><span style="color:#006600;font-weight:bold;">]</span>  <span style="color:#006600;font-weight:bold;">&#124;&#124;</span>= <span style="color:#996600;">''</span>
        options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:joins</span><span style="color:#006600;font-weight:bold;">]</span>  <span style="color:#006600;font-weight:bold;">&#60;&#60;</span> <span style="color:#006600;font-weight:bold;">&#60;&#60;-</span><span style="color:#9966cc;font-weight:bold;">END</span>
          INNER JOIN posts_tags AS inner_posts_tags ON posts.<span style="color:#9900cc;">id</span> = inner_posts_tags.<span style="color:#9900cc;">post_id</span>
          INNER JOIN tags AS inner_tags ON inner_tags.<span style="color:#9900cc;">id</span> = inner_posts_tags.<span style="color:#9900cc;">tag_id</span>
        <span style="color:#9966cc;font-weight:bold;">END</span>
        add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, tags.<span style="color:#9900cc;">map</span> <span style="color:#006600;font-weight:bold;">{</span> <span style="color:#996600;">'inner_tags.name = ?'</span> <span style="color:#006600;font-weight:bold;">}</span>.<span style="color:#9900cc;">join</span><span style="color:#006600;font-weight:bold;">(</span><span style="color:#996600;">' OR '</span><span style="color:#006600;font-weight:bold;">)</span>, <span style="color:#006600;font-weight:bold;">*</span>tags<span style="color:#006600;font-weight:bold;">)</span>
      <span style="color:#9966cc;font-weight:bold;">end</span>
      find_without_tags<span style="color:#006600;font-weight:bold;">(</span><span style="color:#006600;font-weight:bold;">*</span><span style="color:#006600;font-weight:bold;">(</span>args <span style="color:#006600;font-weight:bold;">+</span> <span style="color:#006600;font-weight:bold;">[</span>options<span style="color:#006600;font-weight:bold;">]</span><span style="color:#006600;font-weight:bold;">)</span><span style="color:#006600;font-weight:bold;">)</span>
    <span style="color:#9966cc;font-weight:bold;">end</span>
    alias_method_chain <span style="color:#ff3333;font-weight:bold;">:find</span>, <span style="color:#ff3333;font-weight:bold;">:tags</span>

    <span style="color:#9966cc;font-weight:bold;">def</span> find_with_query<span style="color:#006600;font-weight:bold;">(</span><span style="color:#006600;font-weight:bold;">*</span>args<span style="color:#006600;font-weight:bold;">)</span>
      options = extract_options_from_args!<span style="color:#006600;font-weight:bold;">(</span>args<span style="color:#006600;font-weight:bold;">)</span>
      <span style="color:#9966cc;font-weight:bold;">if</span> query = options.<span style="color:#9900cc;">delete</span><span style="color:#006600;font-weight:bold;">(</span><span style="color:#ff3333;font-weight:bold;">:query</span><span style="color:#006600;font-weight:bold;">)</span>
        <span style="color:#9966cc;font-weight:bold;">if</span> query.<span style="color:#9900cc;">empty</span>?
          add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, <span style="color:#996600;">'false'</span><span style="color:#006600;font-weight:bold;">)</span>
        <span style="color:#9966cc;font-weight:bold;">else</span>
          term = <span style="color:#996600;">"%#{query}%"</span>
          add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, <span style="color:#996600;">"posts.content LIKE ? OR posts.title LIKE ?"</span>, term, term<span style="color:#006600;font-weight:bold;">)</span>
        <span style="color:#9966cc;font-weight:bold;">end</span>
      <span style="color:#9966cc;font-weight:bold;">end</span>
      find_without_query<span style="color:#006600;font-weight:bold;">(</span><span style="color:#006600;font-weight:bold;">*</span><span style="color:#006600;font-weight:bold;">(</span>args <span style="color:#006600;font-weight:bold;">+</span> <span style="color:#006600;font-weight:bold;">[</span>options<span style="color:#006600;font-weight:bold;">]</span><span style="color:#006600;font-weight:bold;">)</span><span style="color:#006600;font-weight:bold;">)</span>
    <span style="color:#9966cc;font-weight:bold;">end</span>
    alias_method_chain <span style="color:#ff3333;font-weight:bold;">:find</span>, <span style="color:#ff3333;font-weight:bold;">:query</span>

    protected

    <span style="color:#9966cc;font-weight:bold;">def</span> add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, condition, <span style="color:#006600;font-weight:bold;">*</span>args<span style="color:#006600;font-weight:bold;">)</span>
      condition = args.<span style="color:#9900cc;">empty</span>? ? condition : <span style="color:#006600;font-weight:bold;">[</span>condition, <span style="color:#006600;font-weight:bold;">*</span>args<span style="color:#006600;font-weight:bold;">]</span>
      <span style="color:#9966cc;font-weight:bold;">if</span> options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:conditions</span><span style="color:#006600;font-weight:bold;">]</span>.<span style="color:#0000ff;font-weight:bold;">nil</span>?
        options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:conditions</span><span style="color:#006600;font-weight:bold;">]</span> = condition
      <span style="color:#9966cc;font-weight:bold;">else</span>
        options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:conditions</span><span style="color:#006600;font-weight:bold;">]</span> = sanitize_sql<span style="color:#006600;font-weight:bold;">(</span>options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:conditions</span><span style="color:#006600;font-weight:bold;">]</span><span style="color:#006600;font-weight:bold;">)</span> <span style="color:#006600;font-weight:bold;">+</span> <span style="color:#996600;">" AND (#{sanitize_sql(condition)})"</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>
<span style="color:#9966cc;font-weight:bold;">end</span></pre>
<pre style="width:auto;clear:none;font-size:12px;line-height:1.333;white-space:pre;font-family:monospace;margin:0;"><span style="color:#9966cc;"><strong>
</strong></span></pre>
<p><strong>Percebendo que isso não tava muito DRY, ele recorreu à metaprogramação:</strong></p>
<pre style="width:auto;clear:none;font-size:12px;line-height:1.333;white-space:pre;font-family:monospace;margin:0;"><span style="color:#9966cc;font-weight:bold;">class</span> Post <span style="color:#006600;font-weight:bold;">&#60;</span> <span style="color:#6666ff;font-weight:bold;">ActiveRecord::Base</span>
  <span style="color:#9966cc;font-weight:bold;">class</span> <span style="color:#006600;font-weight:bold;">&#60;&#60;</span> <span style="color:#0000ff;font-weight:bold;">self</span>
    <span style="color:#9966cc;font-weight:bold;">def</span> handle_find_option<span style="color:#006600;font-weight:bold;">(</span>name, <span style="color:#006600;font-weight:bold;">&#38;</span>block<span style="color:#006600;font-weight:bold;">)</span>
      eigenclass = <span style="color:#9966cc;font-weight:bold;">class</span> <span style="color:#006600;font-weight:bold;">&#60;&#60;</span> <span style="color:#0000ff;font-weight:bold;">self</span>; <span style="color:#0000ff;font-weight:bold;">self</span>; <span style="color:#9966cc;font-weight:bold;">end</span>
      eigenclass.<span style="color:#9900cc;">send</span> <span style="color:#ff3333;font-weight:bold;">:define_method</span>, <span style="color:#996600;">"find_with_#{name}_handled"</span> <span style="color:#9966cc;font-weight:bold;">do</span> <span style="color:#006600;font-weight:bold;">&#124;*</span>args<span style="color:#006600;font-weight:bold;">&#124;</span>
        options = extract_options_from_args!<span style="color:#006600;font-weight:bold;">(</span>args<span style="color:#006600;font-weight:bold;">)</span>
        <span style="color:#9966cc;font-weight:bold;">if</span> option = options.<span style="color:#9900cc;">delete</span><span style="color:#006600;font-weight:bold;">(</span>name<span style="color:#006600;font-weight:bold;">)</span>
          block<span style="color:#006600;font-weight:bold;">[</span>options, option<span style="color:#006600;font-weight:bold;">]</span>
        <span style="color:#9966cc;font-weight:bold;">end</span>
        send<span style="color:#006600;font-weight:bold;">(</span><span style="color:#996600;">"find_without_#{name}_handled"</span>, <span style="color:#006600;font-weight:bold;">*</span><span style="color:#006600;font-weight:bold;">(</span>args <span style="color:#006600;font-weight:bold;">+</span> <span style="color:#006600;font-weight:bold;">[</span>options<span style="color:#006600;font-weight:bold;">]</span><span style="color:#006600;font-weight:bold;">)</span><span style="color:#006600;font-weight:bold;">)</span>
      <span style="color:#9966cc;font-weight:bold;">end</span>
      eigenclass.<span style="color:#9900cc;">send</span> <span style="color:#ff3333;font-weight:bold;">:alias_method_chain</span>, <span style="color:#ff3333;font-weight:bold;">:find</span>, <span style="color:#996600;">"#{name}_handled"</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>

<span style="color:#9966cc;font-weight:bold;">class</span> Post <span style="color:#006600;font-weight:bold;">&#60;</span> <span style="color:#6666ff;font-weight:bold;">ActiveRecord::Base</span>
  handle_find_option<span style="color:#006600;font-weight:bold;">(</span><span style="color:#ff3333;font-weight:bold;">:tags</span><span style="color:#006600;font-weight:bold;">)</span> <span style="color:#9966cc;font-weight:bold;">do</span> <span style="color:#006600;font-weight:bold;">&#124;</span>options, tags<span style="color:#006600;font-weight:bold;">&#124;</span>
    options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:select</span><span style="color:#006600;font-weight:bold;">]</span> <span style="color:#006600;font-weight:bold;">&#124;&#124;</span>= <span style="color:#996600;">'posts.*'</span>
    options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:joins</span><span style="color:#006600;font-weight:bold;">]</span>  <span style="color:#006600;font-weight:bold;">&#124;&#124;</span>= <span style="color:#996600;">''</span>
    options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:joins</span><span style="color:#006600;font-weight:bold;">]</span>  <span style="color:#006600;font-weight:bold;">&#60;&#60;</span> <span style="color:#006600;font-weight:bold;">&#60;&#60;-</span><span style="color:#9966cc;font-weight:bold;">END</span>
      INNER JOIN posts_tags AS inner_posts_tags ON posts.<span style="color:#9900cc;">id</span> = inner_posts_tags.<span style="color:#9900cc;">post_id</span>
      INNER JOIN tags AS inner_tags ON inner_tags.<span style="color:#9900cc;">id</span> = inner_posts_tags.<span style="color:#9900cc;">tag_id</span>
    <span style="color:#9966cc;font-weight:bold;">END</span>
    add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, tags.<span style="color:#9900cc;">map</span> <span style="color:#006600;font-weight:bold;">{</span> <span style="color:#996600;">'inner_tags.name = ?'</span> <span style="color:#006600;font-weight:bold;">}</span>.<span style="color:#9900cc;">join</span><span style="color:#006600;font-weight:bold;">(</span><span style="color:#996600;">' OR '</span><span style="color:#006600;font-weight:bold;">)</span>, <span style="color:#006600;font-weight:bold;">*</span>tags<span style="color:#006600;font-weight:bold;">)</span>
  <span style="color:#9966cc;font-weight:bold;">end</span>

  handle_find_option<span style="color:#006600;font-weight:bold;">(</span><span style="color:#ff3333;font-weight:bold;">:query</span><span style="color:#006600;font-weight:bold;">)</span> <span style="color:#9966cc;font-weight:bold;">do</span> <span style="color:#006600;font-weight:bold;">&#124;</span>options, query<span style="color:#006600;font-weight:bold;">&#124;</span>
    <span style="color:#9966cc;font-weight:bold;">if</span> query.<span style="color:#9900cc;">empty</span>?
      add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, <span style="color:#996600;">'false'</span><span style="color:#006600;font-weight:bold;">)</span>
    <span style="color:#9966cc;font-weight:bold;">else</span>
      term = <span style="color:#996600;">"%#{query}%"</span>
      add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, <span style="color:#996600;">"posts.content LIKE ? OR posts.title LIKE ?"</span>, term, term<span style="color:#006600;font-weight:bold;">)</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>
<p>Uma alternativa usando super:</p>
<pre style="width:auto;clear:none;font-size:12px;line-height:1.333;white-space:pre;font-family:monospace;margin:0;"><span style="color:#9966cc;font-weight:bold;">class</span> Post <span style="color:#006600;font-weight:bold;">&#60;</span> <span style="color:#6666ff;font-weight:bold;">ActiveRecord::Base</span>
  <span style="color:#9966cc;font-weight:bold;">class</span> <span style="color:#006600;font-weight:bold;">&#60;&#60;</span> <span style="color:#0000ff;font-weight:bold;">self</span>
    <span style="color:#9966cc;font-weight:bold;">def</span> find<span style="color:#006600;font-weight:bold;">(</span><span style="color:#006600;font-weight:bold;">*</span>args<span style="color:#006600;font-weight:bold;">)</span>
      options = args.<span style="color:#9900cc;">last</span>.<span style="color:#9900cc;">is_a</span>?<span style="color:#006600;font-weight:bold;">(</span><span style="color:#cc00ff;font-weight:bold;">Hash</span><span style="color:#006600;font-weight:bold;">)</span> ? args.<span style="color:#9900cc;">last</span> : <span style="color:#006600;font-weight:bold;">{</span><span style="color:#006600;font-weight:bold;">}</span>
      add_tag_conditions<span style="color:#006600;font-weight:bold;">(</span>options<span style="color:#006600;font-weight:bold;">)</span>
      add_query_conditions<span style="color:#006600;font-weight:bold;">(</span>options<span style="color:#006600;font-weight:bold;">)</span>
      <span style="color:#9966cc;font-weight:bold;">super</span>
    <span style="color:#9966cc;font-weight:bold;">end</span>

    private
    <span style="color:#9966cc;font-weight:bold;">def</span> add_tag_conditions<span style="color:#006600;font-weight:bold;">(</span>options<span style="color:#006600;font-weight:bold;">)</span>
      <span style="color:#9966cc;font-weight:bold;">if</span> tag = options.<span style="color:#9900cc;">delete</span><span style="color:#006600;font-weight:bold;">(</span><span style="color:#ff3333;font-weight:bold;">:tags</span><span style="color:#006600;font-weight:bold;">)</span>
        options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:select</span><span style="color:#006600;font-weight:bold;">]</span> <span style="color:#006600;font-weight:bold;">&#124;&#124;</span>= <span style="color:#996600;">'posts.*'</span>
        options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:joins</span><span style="color:#006600;font-weight:bold;">]</span>  <span style="color:#006600;font-weight:bold;">&#124;&#124;</span>= <span style="color:#996600;">''</span>
        options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:joins</span><span style="color:#006600;font-weight:bold;">]</span>  <span style="color:#006600;font-weight:bold;">&#60;&#60;</span> <span style="color:#006600;font-weight:bold;">&#60;&#60;-</span><span style="color:#9966cc;font-weight:bold;">END</span>
          INNER JOIN posts_tags AS inner_posts_tags ON posts.<span style="color:#9900cc;">id</span> = inner_posts_tags.<span style="color:#9900cc;">post_id</span>
          INNER JOIN tags AS inner_tags ON inner_tags.<span style="color:#9900cc;">id</span> = inner_posts_tags.<span style="color:#9900cc;">tag_id</span>
        <span style="color:#9966cc;font-weight:bold;">END</span>
        add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, tags.<span style="color:#9900cc;">map</span> <span style="color:#006600;font-weight:bold;">{</span> <span style="color:#996600;">'inner_tags.name = ?'</span> <span style="color:#006600;font-weight:bold;">}</span>.<span style="color:#9900cc;">join</span><span style="color:#006600;font-weight:bold;">(</span><span style="color:#996600;">' OR '</span><span style="color:#006600;font-weight:bold;">)</span>, <span style="color:#006600;font-weight:bold;">*</span>tags<span style="color:#006600;font-weight:bold;">)</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;">def</span> add_query_conditions<span style="color:#006600;font-weight:bold;">(</span>options<span style="color:#006600;font-weight:bold;">)</span>
      <span style="color:#9966cc;font-weight:bold;">if</span> query = options.<span style="color:#9900cc;">delete</span><span style="color:#006600;font-weight:bold;">(</span><span style="color:#ff3333;font-weight:bold;">:query</span><span style="color:#006600;font-weight:bold;">)</span>
        <span style="color:#9966cc;font-weight:bold;">if</span> query.<span style="color:#9900cc;">empty</span>?
          add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, <span style="color:#996600;">'false'</span><span style="color:#006600;font-weight:bold;">)</span>
        <span style="color:#9966cc;font-weight:bold;">else</span>
          term = <span style="color:#996600;">"%#{query}%"</span>
          add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, <span style="color:#996600;">"posts.content LIKE ? OR posts.title LIKE ?"</span>, term, term<span style="color:#006600;font-weight:bold;">)</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>

    <span style="color:#9966cc;font-weight:bold;">def</span> add_to_conditions<span style="color:#006600;font-weight:bold;">(</span>options, condition, <span style="color:#006600;font-weight:bold;">*</span>args<span style="color:#006600;font-weight:bold;">)</span>
      condition = args.<span style="color:#9900cc;">empty</span>? ? condition : <span style="color:#006600;font-weight:bold;">[</span>condition, <span style="color:#006600;font-weight:bold;">*</span>args<span style="color:#006600;font-weight:bold;">]</span>
      <span style="color:#9966cc;font-weight:bold;">if</span> options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:conditions</span><span style="color:#006600;font-weight:bold;">]</span>.<span style="color:#0000ff;font-weight:bold;">nil</span>?
        options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:conditions</span><span style="color:#006600;font-weight:bold;">]</span> = condition
      <span style="color:#9966cc;font-weight:bold;">else</span>
        options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:conditions</span><span style="color:#006600;font-weight:bold;">]</span> = sanitize_sql<span style="color:#006600;font-weight:bold;">(</span>options<span style="color:#006600;font-weight:bold;">[</span><span style="color:#ff3333;font-weight:bold;">:conditions</span><span style="color:#006600;font-weight:bold;">]</span><span style="color:#006600;font-weight:bold;">)</span> <span style="color:#006600;font-weight:bold;">+</span> <span style="color:#996600;">" AND (#{sanitize_sql(condition)})"</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>
<span style="color:#9966cc;font-weight:bold;">end</span></pre>
<hr />
Nós apenas substituímos, modificamos com as soluções apropriadas e chamamos o super. Essa mesma técnica funciona bem com suas próprias modificações no ActionController de sua aplicação, em qualquer caso em que a API do Rails inclui o uso de subclasses. Galera: É pra isso que existem as subclasses!</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
