<?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>rails &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/rails/</link>
	<description>Feed of posts on WordPress.com tagged "rails"</description>
	<pubDate>Fri, 16 May 2008 04:03:48 +0000</pubDate>

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

<item>
<title><![CDATA[Ruby e Rails x IDE Netbeans 6.1]]></title>
<link>http://lcmetzger.wordpress.com/?p=10</link>
<pubDate>Fri, 16 May 2008 01:38:07 +0000</pubDate>
<dc:creator>lcmetzger</dc:creator>
<guid>http://lcmetzger.wordpress.com/?p=10</guid>
<description><![CDATA[Após conversar com alguns colegas sobre IDEs para desenvolvimento em Ruby e Rails, novamente me sen]]></description>
<content:encoded><![CDATA[<p>Após conversar com alguns colegas sobre IDEs para desenvolvimento em Ruby e Rails, novamente me senti encorajado a avaliar o Netbeans, e confesso que fiquei surpreso:</p>
<ul>
<li><strong>GEMs</strong>: Fácil gerenciamento, mostra o que está instalado, o que pode ser atualizado, novos gems e possibilidade de incluir novas URLS;</li>
<li><strong>Plugins</strong>: Idem ao item anterior;</li>
<li><strong>Editor</strong>: Percebi que o editor está mais rápido que de versões que avaliei anteriormente, principalmente com o <em>code completion</em> e os textos de ajuda, inclusive existe e funciona o <em>code completion</em> para os arquivos erb da camada <em>view</em>;</li>
<li><strong>Rake</strong>: Todas as task estão disponíveis e bem classificadas no menu; As <em>tasks</em> que são utilizadas são empilhadas no menu para rápido acesso;</li>
</ul>
<p>Sempre utilizei o Eclipse, porém vou passar a utilizar o Netbeans 6.1 para continuar avaliando a IDE, pois o primeiro contato realmente agradou.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Flex on Rails - Envolva-se]]></title>
<link>http://silvadeveloper.wordpress.com/?p=31</link>
<pubDate>Fri, 16 May 2008 00:10:57 +0000</pubDate>
<dc:creator>Silva Developer</dc:creator>
<guid>http://silvadeveloper.wordpress.com/?p=31</guid>
<description><![CDATA[Tudo o que você precisa saber sobre como se envolver ainda mais com as tecnologias Flex e Ruby on R]]></description>
<content:encoded><![CDATA[<p style="text-align:justify;">Tudo o que você precisa saber sobre como se envolver ainda mais com as tecnologias Flex e Ruby on Rails esta aqui, de forma clara, simples e objetiva, em um único post:</p>
<p><strong>Envolva-se com Ruby: </strong></p>
<p>Documentação: Consulte <a href="http://www.ruby-doc.org/" target="_blank">aqui</a>.<br />
Fórum: <a href="http://www.ruby-forum.com/" target="_blank">Ruby-Fórum</a>.<br />
Grupos: <a href="http://groups.google.com.br/group/ruby-talk-google?hl=pt-BR&#38;lnk=srg" target="_blank">Ruby-talk-google</a>.<br />
e-Books: <a href="http://aprendaaprogramar.rubyonrails.pro.br/" target="_blank">Aprenda a programar Ruby</a>.<a href="http://aprendaaprogramar.rubyonrails.pro.br/" target="_blank"></a></p>
<p><strong>Envolva-se com Rails:</strong></p>
<p>Documentação: Consulte <a href="http://api.rubyonrails.org/" target="_blank">aqui</a>.<a href="http://api.rubyonrails.org/" target="_blank"></a></p>
<p>Foruns: <a href="http://www.rubyonrails.pro.br/" target="_blank">Rails Brasil</a>, <a href="http://rubyonbr.org" target="_blank">Ruby on Br</a>, <a href="http://www.ruby-forum.com/forum/3" target="_blank">Ruby-Fórum Rails</a>. <a href="http://www.rubyonrails.pro.br/" target="_blank"></a></p>
<p>Grupos: <a href="http://groups.google.com.br/group/rails-br?hl=pt-BR" target="_blank">rails-br</a> e <a href="http://groups.google.com.br/group/rails-br?hl=pt-BR" target="_blank"></a><a href="http://groups.google.com.br/group/rubyonrails-talk?hl=pt-BR" target="_blank">Ruby on Rails:Talk</a><a href="http://groups.google.com.br/group/rubyonrails-talk?hl=pt-BR" target="_blank"></a></p>
<p>Tutorial: Rolling with Rails 2.0 by Fabio Akita: <a href="http://www.akitaonrails.com/2008/2/1/rolling-with-rails-2-0-o-primeiro-tutorial-completo-parte-1" target="_blank">Parte 1</a> e <a href="http://www.akitaonrails.com/2008/2/1/rolling-with-rails-2-0-o-primeiro-tutorial-completo-parte-2" target="_blank">Parte 2</a>.</p>
<p>Podcasts: <a href="http://www.rubyonrails.pro.br/podcasts" target="_blank">Rails Podcast Brasil</a></p>
<p>Screencasts: <a href="http://peepcode.com/" target="_blank">PeepCode (pago)</a> e <a href="http://railscasts.com/" target="_blank">Railscasts (grátis)</a></p>
<p>Melhores blogs: <a href="http://www.akitaonrails.com" target="_blank">Fabio Akita</a>, <a href="http://www.nomedojogo.com" target="_blank">Carlos Branco</a> e <a href="http://www.blog.egenial.com.br" target="_blank">Carlos Eduardo e-Genial</a>.</p>
<p><strong>Envolva-se com Flex:</strong></p>
<p>Documentação: Consulte <a href="http://http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">aqui</a>.</p>
<p>Foruns: <a href="http://forum.flexbrasil.com.br/index.php" target="_blank">Fórum FlexBrasil</a> e <a href="http://flexbrasil.informe.com/" target="_blank">Fórum Informe Flex-Brasil</a></p>
<p>Grupos: <a href="http://groups.google.com.br/group/flexbrasil?hl=pt-BR" target="_blank">Flex-Brasil Google</a>, <a href="http://br.groups.yahoo.com/group/flex-brasil/" target="_blank">Flex-Brasil Yahoo</a>, e <a href="http://groups.google.com.br/group/flexdev?hl=pt-BR" target="_blank">Flexdev</a>.</p>
<p>Tutorial: <a href="http://www.flex888.com/2007/09/20/10-flex-and-ruby-on-rails-integration-examples.html" target="_blank">Seleção de 10 tutoriais sobre flex e flex on rails</a>.</p>
<p>Podcasts: <a href="http://www.theflexshow.com/blog/index.cfm/2007/1/9/The-Flex-Show--Episode-1" target="_blank">The flex show podcasts</a>.</p>
<p>Screencasts: <a href="http://www.adobe.com/products/flex/media/flexapp/" target="_blank">Adobe Flex Media Screencast</a>.</p>
<p>Melhores blogs: <a href="http://www.theflexshow.com/blog/" target="_blank">The flex show</a>, <a href="http://cfgigolo.com" target="_blank">Fabio Terracini</a>, <a href="http://www.blog.egenial.com.br" target="_blank">Carlos Eduardo e-Genial</a>.</p>
<p>Extras: <a href="http://flex.org/" target="_blank">Portal Flex</a>, <a href="http://flex.org/showcase/" target="_blank">Flex Showcases</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Flex on Rails - Inicie]]></title>
<link>http://silvadeveloper.wordpress.com/?p=30</link>
<pubDate>Thu, 15 May 2008 17:00:08 +0000</pubDate>
<dc:creator>Silva Developer</dc:creator>
<guid>http://silvadeveloper.wordpress.com/?p=30</guid>
<description><![CDATA[Kit essencial para desenvolvimento Flex on Rails

Como uma forma de tentar evitar que meus caros ami]]></description>
<content:encoded><![CDATA[<p style="text-align:justify;"><strong>Kit essencial para desenvolvimento Flex on Rails</strong><strong><br />
</strong></p>
<p style="text-align:justify;">Como uma forma de tentar evitar que meus caros amigos desenvolvedores iniciantes em ruby on rails e Flex percam seus preciosos tempos e queimem neurônios, criei este tutorial passo-a-passo, onde mostro quais softwares e versões que você precisa ter instalado em sua máquina para desenvolvedor aplicações RIA, flex on rails.</p>
<p><strong>Composição do kit:</strong></p>
<p>Basicamente o kit de softwares necessários para você desenvolver aplicações Flex on Rails, é o seguinte:</p>
<p><strong>1) Mysql;</strong></p>
<p>Versão recomendada: 5.0<br />
Observação: Recomendo posteriormente a instalação da ferramenta Mysql-front para visualização mais rápida e dinâmica.<br />
Clique <a href="http://dev.mysql.com/downloads/mysql/5.0.html" target="_blank">aqui</a> para baixar.</p>
<p><strong>2) Ruby;</strong></p>
<p>Versão recomenda: 1.8.6 última estável<br />
Observação:<br />
Clique <a href="http://rubyforge.org/frs/?group_id=426" target="_blank">aqui</a> para baixar.</p>
<p><strong>3) Rails;</strong></p>
<p>Versão recomendada: 2.0.2 última estável<br />
Observação: Deve ser instalado obrigatoriamente depois do ruby.<br />
Link para download: abrir o cmd e digitar o seguinte comando: gem install rails --include-dependencies</p>
<p><strong>4) Java Runtime;</strong></p>
<p>Versão: 6 atualização 5<br />
Observação: Utilizado pelo Flex 3 Builder e do Aptana RadRails, todos os 2 são derivados do eclipse.<br />
Clique <a href="http://www.java.com/pt_BR/download/windows_xpi.jsp?locale=pt_BR&#38;host=www.java.com:80" target="_blank">aqui</a> para baixar.</p>
<p><strong>5) Aptana Studio RadRails;</strong></p>
<p>Versão: Aptana Studio 1.1 e do plugin RadRails 1.0.1<br />
Observação: Primeiramente você deve baixar o Aptana Studio 1.1 e depois, do próprio software instale o plugin RadRails versão 1.0.1.<br />
Clique <a href="http://www.aptana.com/studio/download" target="_blank">aqui</a> para baixar.</p>
<p><strong>6) Adobe Flex 3 Builder;</strong></p>
<p>Versão: 3.0<br />
Observação: Este software é pago, porém no site do fabricante, Adobe, você poderá realizar um cadastro para obter versão trial por 90 dias.<br />
Clique <a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3email" target="_blank">aqui</a> para baixar.</p>
<p><strong>Cronograma e Ordem da instalação:</strong></p>
<p style="text-align:justify;"><strong>1) Mysql</strong>, instale primeiramente o mysql 5.0 server na sua máquina, pois, durante a instalação dos softwares server-sides, como rails, ele buscará pelo mysql instalado para incluir o caminho (path) em sua biblioteca interna;</p>
<p style="text-align:justify;"><strong>2) Ruby</strong>, todos sabemos que o rails é um framework da linguagem ruby, portanto para que o rails funcione você deve instalar primeiramente sua base, que é<br />
o ruby.</p>
<p style="text-align:justify;"><strong>3) Rails</strong>, depois de instalado o ruby, instale o rails que é muito simples e a instalação não poderia ser menos dinâmica que o framework, para instalá-lo basta abrir o cmd e digitar o seguinte comando:</p>
<p style="text-align:justify;"><strong>gem install rails --include-dependencies</strong></p>
<p style="text-align:justify;"><strong>4) Java Runtime</strong>, como iremos trabalhar com IDE Aptana RadRails, cuja qual iremos instalar no próximo passo, como todos sabemos, todo aplicativo baseado no eclipse, usa a plataforma java, por isso, caso ainda não tenha, instale-a previamente antes do Aptana RadRails.</p>
<p style="text-align:justify;"><strong>5) Aptana RadRails</strong>, como sabemos no mundo de hoje tempo é dinheiro, por isso, existem diversas editores que automatizam ainda mais as funções do rails, dentre elas está o Aptana Studio RadRails, que para mim, é a melhor ferramenta.</p>
<p style="text-align:justify;"><strong>6) Adobe Flex 3 Builder</strong>, depois de tudo pronto agora só falta a parte charmosa e visual do seu kit, instale o flex 3 builder, que será a camada de visualização de sua aplicação feita em rails. Como todos sabemos, todas as apps rails utilizam a estrutura MVC, que significa, Model, View, Controller. Quando juntamos as tecnologias client-side Flex e server-side Rails, o flex incorpora a função das views da aplicação rails, que é no meu entender, o grande charme e transformação visual das aplicações, o que difere sua app das comuns estáticas que se vê por aí.</p>
<p>Bom por agora é só, espero que tenham gostado de mais esta contribuição. Abraço a todos!.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[SelfDiagnose for Ruby on Rails]]></title>
<link>http://philemonworks.wordpress.com/?p=22</link>
<pubDate>Thu, 15 May 2008 11:41:49 +0000</pubDate>
<dc:creator>emicklei</dc:creator>
<guid>http://philemonworks.wordpress.com/?p=22</guid>
<description><![CDATA[SelfDianogse is a library of tasks to diagnose a running system with respect to its dependent extern]]></description>
<content:encoded><![CDATA[<p><a href="http://selfdiagnose.sourceforge.net">SelfDianogse</a> is a library of tasks to diagnose a running system with respect to its dependent external resources. Recently, I did some Rails developement and was thinking about how to implement it for the Ruby on Rails framework ? Obvious choice is to make a plugin that on installation adds the SelfDiagnoseController.rb to the application. Because of the scripting nature of Rails framework, putting the configuration in XML (as it is done for Java) is not the Ruby-way. So either use YAML or put the configuration directly into the controller. Let's investigate the latter.</p>
<pre>
class SelfdiagnoseController &#60; ActionController
  include SelfDiagnose

  tasks {
      check_database_connection 'mysql'
      check_directory_readable '/path/to/dir'
      check_log_writeable 'production.log'
      check_url_accessable 'http://s3browse.com'
  }
end
</pre>
<p>And the module would be defined as something similar to:</p>
<pre>
module SelfDiagnose
  def tasks
    yield if block_given?
  end
  def check_database_connection(db_name)
    # create a new CheckDatabaseConnection task and register it for running
  end
  def check_log_writeable(log_name)
    # create a new CheckLogWriteable task and register it for running
  end
end # module
</pre>
<p>Looking back at this approach, I don't see the need for having a task registration in the Rails version of SelfDiagnose. I might as well implement the controller like this:</p>
<pre>
class SelfdiagnoseController &#60; ActionController
  include SelfDiagnose

  def index
      check_database_connection 'mysql'
      check_directory_readable '/path/to/dir'
      check_log_writeable 'production.log'
      check_url_accessable 'http://s3browse.com'
  end
end
</pre>
<p>Then, the index.html.erb will put together a nice report of the results.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[[Updated] The world is a ghetto]]></title>
<link>http://psinc.wordpress.com/2008/05/14/updated-the-world-is-a-ghetto/</link>
<pubDate>Wed, 14 May 2008 17:31:03 +0000</pubDate>
<dc:creator>László Gyula</dc:creator>
<guid>http://psinc.wordpress.com/2008/05/14/updated-the-world-is-a-ghetto/</guid>
<description><![CDATA[Most bizarre Git service and other stupid Rails powered &#8220;businesses&#8221;
Anyone developing u]]></description>
<content:encoded><![CDATA[<p><a href="http://groovie.org/articles/2008/05/06/most-bizarre-git-service-and-other-stupid-rails-powered-businesses">Most bizarre Git service and other stupid Rails powered "businesses"</a></p>
<p>Anyone developing using some relatively cutting-edge framework/methodology/language/frogs/shoes/moustach/... should be familiar with the "both the answer and the shit is blowin' in the wind" effect: simple sollutions attract good developers, good developers advertise what they work with, which brings new users, and the new users in fact attract the sharks.</p>
<p>The sharks -both literal ones and the ones manifested as coders- are pretty stupid creatures: they swimm around, trying to smell some blood (aka. copy'n'paste), and scare away anybody with some common sense left in 'em. </p>
<p>Rails was once nice. I've managed to <a target="_blank" href="http://statravel.hu">spill out an app</a> in a realtively short time with 0.9, which worked like a charm. And just like when you marry someone, after the first year the problems start to appear: she forgets to go to the gym, and, well... another year passes by and look... that fat b**ch wearing your wedding ring just isn't the one you supposed to live your life with...</p>
<p>And now github (no you fck'ers, I won't link you) opens up with a business plan <a target="_blank" href="http://github.com/plans">like this</a> . Geez, I've seen this somewhere... Does anyone remember when you first saw <a target="_blank" href="http://www.basecamphq.com/signup">basecamp's similar page?</a> A while ago, basecamp's version had the exact same number of rows and columns, with almost the same CSS classes and ID's. </p>
<p>Or perhaps is there a ruby gem called <code>gem_business_plan</code>? Anyway. The rails project just does what its name says: it lays the rails for you, and if you're lazy, the only direction you're heading is the exact same destination as the guys who laid the rails...</p>
<p>I'm really looking forward to some hidden gem found only in the dark corners of the net, some really exotic freakish 'ish toolset on a desert island...</p>
<p>[Update]</p>
<p>I'm really getting bored seeing the same signup/"plans" for a gajillion sites, so I've decided to create a little list I can expand when my frustration level exceeds the threshold.</p>
<ul>
<li><a target="_blank" href="http://www.corepage.com">http://www.corepage.com</a></li>
<li><a target="_blank" href="https://scoutapp.com/subscriptions">https://scoutapp.com/subscriptions</a></li>
</ul>
]]></content:encoded>
</item>
<item>
<title><![CDATA[IE6 Accept Header is Faulty and Makes format.any Suck]]></title>
<link>http://geminstallthat.wordpress.com/?p=33</link>
<pubDate>Wed, 14 May 2008 17:01:29 +0000</pubDate>
<dc:creator>reidmix</dc:creator>
<guid>http://geminstallthat.wordpress.com/?p=33</guid>
<description><![CDATA[I&#8217;ve been using the awesome acts_as_authenticated plugin as the basis for user login and autho]]></description>
<content:encoded><![CDATA[<p>I've been using the awesome <a title="acts_as_authenticated wiki page at rubyonrails" href="http://wiki.rubyonrails.org/rails/pages/Acts_as_authenticated">acts_as_authenticated</a> plugin as the basis for user login and authorization.  Its <strong>access_denied</strong> method takes advantage of the <strong>ActionController::MimeResponds.any</strong> method which will be invoked on a <strong>login_required</strong> before filter:</p>
<p>[sourcecode language="ruby"]<br />
    def access_denied<br />
      respond_to do &#124;format&#124;<br />
        format.html do<br />
          store_location<br />
          redirect_to new_session_path<br />
        end<br />
        format.any do<br />
          request_http_basic_authentication 'Web Password'<br />
        end<br />
      end<br />
    end<br />
[/sourcecode]</p>
<p>This code essentially says, if it's an html request, store the original request and redirect to the login page, any other requests get the 401 Unauthorized header which the user agent can then use to initiate an HTTP Auth.  This bit of code only works correctly with Edge Rail's <a title="Rails Changeset 8987" href="http://dev.rubyonrails.org/changeset/8987">8987 Changeset</a> that allows any to act as a <a title="Rails Ticket #11140" href="http://dev.rubyonrails.org/ticket/11140">catch-all for any request mime-types not already specified</a>.</p>
<p><em>Awesome!</em><br />
Except when Internet Explorer 6 comes into the picture and happily sends this<br />
<a title="Intermittent IE failures" href="http://intertwingly.net/blog/2007/08/23/Intermittent-IE-failures">strange</a> and <a title="IEBlog where users request complete headers" href="http://blogs.msdn.com/ie/archive/2005/07/29/445242.aspx">incomplete</a> <strong>'Accept:'</strong> header:</p>
<p><code>image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*</code></p>
<p>As you can see, it doesn't specify <strong>application/xhtml+xml</strong> or even <strong>text/html</strong> and what's worse is the subsequent requests to the same page sends the catch-all <strong>*/*</strong>.</p>
<p><em>What does this all mean?</em><br />
When IE6 navigates to a page that requires login, instead of redirecting the user to the login page, the user is presented with an HTTP Auth Dialog.  What's worse is that in my application, cookies and other application state for an web-based end-user is set outside of the <strong>login_from_basic_auth</strong> method -- you know -- in my login action.</p>
<p style="text-align:center;"><img style="border:1px solid black;margin:5px;" src="http://geminstallthat.wordpress.com/files/2008/05/httpauth.jpg" alt="HTTP Auth Prompt by IE6" /></p>
<p>My guess is when the <strong>format.any</strong> fix goes out in the next rails release, IE6 users on <strong> acts_as_authenticated</strong> sites are going to be sad-faced.  I'm not entirely sure the correct way to fix this problem but this is how I solved it in my application:</p>
<p>[sourcecode language="ruby"]<br />
class ActionController::AbstractRequest<br />
  def accepts_with_faulty_header<br />
    @env['HTTP_ACCEPT']='*/*' if @env['HTTP_USER_AGENT'] =~ /msie/i and @env['HTTP_USER_AGENT'] !~ /opera&#124;webtv/i<br />
    accepts_without_faulty_header<br />
  end<br />
  alias_method_chain :accepts, :faulty_header<br />
end<br />
[/sourcecode]</p>
<p>Originally, I thought to patch the <strong>Mime::Type.parse</strong> function, but decided that I wanted to make sure to look at the user agent for IE6.  As you can see, I switch the <strong>HTTP_ACCEPT</strong> header to the catch-all <strong>*/*</strong> string  if the<span style="text-decoration:line-through;"> original <strong>HTTP_ACCEPT</strong> header is a match to the exact (bizarre) IE6 string and the</span> <strong>HTTP_USER_AGENT</strong> is IE (matches MSIE but not Opera or WebTV). Then I call the original <strong>ActionController::AbstractRequest.accepts</strong> method.</p>
<p>I'd love to hear your ideas and suggestions -- and if others have run into this problem as I didn't find many users have this exact problem and how they may have solved it.</p>
<p>Update: Based on the conversation in the comments, I've re-written the patch to always change the HTTP_ACCEPT header to the catch-all <strong>*/*</strong> if it is an IE Browser.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[jetty-rails gem - Simple JRuby On Rails Development with Servlet Containers]]></title>
<link>http://fabiokung.wordpress.com/?p=30</link>
<pubDate>Wed, 14 May 2008 05:47:51 +0000</pubDate>
<dc:creator>Fabio Kung</dc:creator>
<guid>http://fabiokung.wordpress.com/?p=30</guid>
<description><![CDATA[This is the first time I&#8217;m writing about it, but jetty-rails is already 0.3!
Most people doing]]></description>
<content:encoded><![CDATA[<p>This is the first time I'm writing about it, but <a href="http://jetty-rails.rubyforge.org/">jetty-rails</a> is already <strong>0.3</strong>!</p>
<p>Most people doing JRuby on Rails development are using JMongrels<a href="#jlet"><sup>1</sup></a> for development and some real Java Application Server in production.</p>
<p>The common flow is:</p>
<p><code>
<pre>
$ jruby script/server
=&#62; Booting Mongrel (use 'script/server webrick' to force WEBrick)
=&#62; Rails application starting on http://0.0.0.0:3000
=&#62; Call with -d to detach
=&#62; Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
</pre>
<p></code></p>
<p>code, code, test, code, code, test, ... (shouldn't it be red-green-refactor?) </p>
<p><code>
<pre>
$ jruby -S warble
$ cp myapp.war $TOMCAT_HOME/webapps
$ $TOMCAT_HOME/bin/startup.sh
</pre>
<p></code></p>
<p>Sure you can automate those things with ant, rake, sake or anything else. Some people are still using the goldspike-plugin, but be warned: I suspect it won't get much more attention.</p>
<p>The great <a href="http://wiki.jruby.org/wiki/Warbler">Warbler</a> from <a href="http://blog.nicksieger.com/">Nick Sieger</a> is becoming the <em>de facto</em> standard for JRuby on Rails packaging. The <a href="http://blog.nicksieger.com/articles/2008/05/08/introducing-jruby-rack">Warbler's recent move from goldspike to JRuby-Rack adapter</a> reveals two interesting points:</p>
<ol>
<li>Goldspike is likely going to be deprecated (or merged with jruby-rack adapter?).</li>
<li>Warbler will soon package any rack compatible application to be runned inside Java Containers. Such applications include Merb, Sinatra, Vintage, Camping ones, <a href="http://rack.rubyforge.org/">and growing</a>...</li>
</ol>
<p>Although Warbler works really well, it introduces complexity in the development cycle. You can no more save code and immediately test it in your browser:</p>
<ol>
<li>change code;</li>
<li>warble it;</li>
<li>deploy war file;</li>
<li><strong>restart server;</strong> (takes long time)</li>
<li>open browser;</li>
<li>change code;</li>
<li>...</li>
</ol>
<p>It breaks one of the most important rails development characteristics: <strong>instant feedback</strong>. During development, it's very important to see changes without have to wait for server/context restarting.</p>
<p>JMongrel and <a href="http://wiki.glassfish.java.net/Wiki.jsp?page=JRuby">Glassfish Gem</a> are good candidates for JRuby on Rails development with instant feedback, but you can't use Java (Servlet specification) specific features, such as <em>web.xml</em>; they aren't complete Servlet Containers. Some things have an alternative in pure-rails as Servlet Filters and Servlet Listeners, but many haven't. Servlet Context might be a good way to share things between rails runtimes. I know railers should <em>"share nothing"</em>, but -hey- sometimes it's <strong>so good</strong> to share!</p>
<p>You can take the Servlet Application Context as your <strong>in-memory cache store</strong> (fragment and page caching), eliminating the need for filesystem or database overhead and even memcached, in many cases.</p>
<p>I had also a specific reason to share the same HttpSession between Rails and "pure Java" applications. Single sign-on wasn't an option, so I needed to run both applications in the same context. I'm going to tell more about it soon.</p>
<p>Anyone can fall in cases, like mine, when you just can't use jmongrel or glassfish_rails. Now, we fortunately have <a href="http://jetty-rails.rubyforge.org">jetty-rails</a> to rescue!</p>
<p>It's a (<del datetime="00">one more</del>) gem to run rails applications, based on the nice <a href="http://wiki.jruby.org/wiki/JRuby_Rack">JRuby-Rack adapter</a>, which I recommend you to take a look. Jetty is a very powerful Servlet Container, known for being pioneer at being embedded and at using NIO Connectors.</p>
<p>The gem creates a Jetty Server with two Handlers. The first is for static content and the last to serve dynamic requests using JRuby-Rack. These handlers are applied in order and request processing stops when one responds. That way, no rails code is runned to serve static content, improving response times. Take a look at the <a href="http://jetty-rails.rubyforge.org/rdoc/">rdocs</a> for more details.</p>
<p>Jetty is also very quick to start. I've measured (in a complete inaccurate way) some start times just for <del datetime="00">ugly</del><a href="#ugly-method"><sup>2</sup></a> comparison:</p>
<p><code>
<pre>$ jruby -v
<strong>ruby 1.8.6 (2008-03-28 rev 6360) [i386-jruby1.1]</strong>
$ time <strong>jruby script/server</strong>
=&#62; Booting Mongrel (use 'script/server webrick' to force WEBrick)
=&#62; Rails application starting on http://0.0.0.0:3000
...
** INT signal received.
Exiting

<strong>real	0m13.947s</strong>
user	0m11.327s
sys	0m0.892s
</pre>
<p></code></p>
<p><code>
<pre>$ ruby -v
<strong>ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]</strong>
$ time <strong>./script/server </strong>
=&#62; Booting Mongrel (use 'script/server webrick' to force WEBrick)
=&#62; Rails application starting on http://0.0.0.0:3000
...
** INT signal received.
Exiting

<strong>real	0m6.273s</strong>
user	0m1.893s
sys	0m0.611s
</pre>
<p></code></p>
<p>With the same JRuby 1.1 (and without Charles recent speedup patch for jruby startup):</p>
<p><code>
<pre>$ time <strong>jruby -S jetty_rails</strong>
2008-05-04 10:50:00.846::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2008-05-04 10:50:01.013::INFO:  jetty-6.1.9
...
2008-05-04 10:50:02.987::INFO:  Started SelectChannelConnector@0.0.0.0:8080

<strong>real	0m7.035s</strong>
user	0m4.387s
sys	0m0.296s
</pre>
<p></code></p>
<p>As you can see, jetty_rails is very close to mongrel running in MRI, but please, don't take those numbers so seriously.</p>
<p>Jetty Rails should be ready to run any rails application (tell me otherwise!) with no dependencies on extra jars. All gems used by the application must be installed in your JRuby. I've made some simple benchmarks with <a href="http://jakarta.apache.org/jmeter/">JMeter</a> and only one thread, firing 500 consecutive requests to a simple rails blog application. All requests pointed to '/posts' controller, and there was only one Post is the MySQL database.</p>
<p>The machine used to run all tests is a Intel Core2 Duo E4500 @ 2.20GHz, 2.0GB RAM, running Ubuntu 7.10, Ruby (MRI) 1.8.6 and JRuby 1.1.1. MRI tests were done using plain ruby activerecord-mysql-adapter and JRuby tests were done using activerecord-jdbcmysql-adapter.</p>
<p>Mongrel: 30.7 req/s<br />
JMongrel: 19.1 req/s</p>
<p>Glassfish Gem: 17.5 req/s<br />
dropping JVM warm time: 23.8 req/s</p>
<p><strong>Jetty Rails</strong>: 18.2 req/s<br />
dropping JVM warm time: <strong>26.6 req/s</strong></p>
<p>This is obviously a simple measure, just to feel how jetty-rails is going. But I'm very happy with the results. If we ignore the time that JVM takes to warm and JIT compile things, jetty-rails comes close to Mongrel! Impressive. I knew Jetty was always very fast, but I really didn't expect those results.</p>
<p><a href="http://github.com/fabiokung/jetty-rails/tree/master/TODO.txt">There is much more to do</a>. Things from the <a href="http://github.com/fabiokung/jetty-rails/tree/master/TODO.txt">roadmap</a> I wanted to see working soon include:</p>
<ul>
<li>read warble.rb configuration files and register extra jars and public folders defined there;</li>
<li>use any custom web.xml defined in config/web.xml (or config/web.erb.xml), following Wabler conventions.</li>
<li>jetty_merb</li>
<li>jetty_camping</li>
<li>...</li>
</ul>
<p>The <a href="http://github.com/fabiokung/jetty-rails/tree/master">source code lives in GitHub</a>. Feel free to fork, contribute, send patches and suggestions!</p>
<p>
<hr>
<ol>
<li><a name="jlet">Can we stop calling everything that comes from Java with that <del datetime="00">damn</del> <strong>J</strong>-at-start or with -<strong>let</strong> termination? ;)</a></li>
<li><a name="ugly-method">I've stopped the processes (ctrl+c) as soon as I saw they were ready to respond to requests.</a></li>
</ol>
]]></content:encoded>
</item>
<item>
<title><![CDATA[ebay_shopping is now a gem (and now at github)]]></title>
<link>http://pushrod.wordpress.com/?p=34</link>
<pubDate>Tue, 13 May 2008 16:54:10 +0000</pubDate>
<dc:creator>autopendium</dc:creator>
<guid>http://pushrod.wordpress.com/?p=34</guid>
<description><![CDATA[
OK. I&#8217;ve jumped on the Git bandwagon, and to celebrate have made the ebay_shopping plugin (a ]]></description>
<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/44458147@N00/263228000/"><img class="alignnone size-full wp-image-35" src="http://pushrod.wordpress.com/files/2008/05/263228000_9513c97026.jpg" alt="" width="500" height="371" /></a></p>
<p>OK. I've jumped on the Git bandwagon, and to celebrate have made the <a href="http://pushrod.wordpress.com/2008/01/13/a-rubyonrails-library-for-the-ebay-shopping-api/">ebay_shopping plugin (a ruby on rails library for eBay's shopping API</a>) into a <a href="http://github.com/ctagg/ebay_shopping/tree">gem</a>, hosted at <a href="http://github.com">Github</a>. It'll take a few days before the rubyforge project is approved and loaded up, but you can still download it from github, or with a github clone.</p>
<p>Why turn it into a gem? Well, it was originally a plugin as that was the easiest and quickest way to do it at the time -- it was generated from a Rails application, after all. It also made things like getting the initial config (from a YAML file in the Rails config directory) a no-brainer, and meant I could use some of the ActiveSupport methods without thinking.</p>
<p>But over the past few weeks, I've been playing around with <a href="http://merbivore.com/">Merb</a>, and decided these benefits are more than outweighed by the greater portability a gem brings. There's also the benefit of versioning and dependencies. Finally, with <a href="http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies">Rails edging away from plugins with 2.1</a>, and the ease of gem generation using <a href="http://newgem.rubyforge.org/">Dr Nic's newgem gem</a>, there's really no reason to stay with the plugin approach. Enter, stage left, the <a href="http://github.com/ctagg/ebay_shopping/tree">ebay_shopping gem</a>.</p>
<p>If you're already using the plugin, there's no hurry to change. If not, give the gem a try and let me know how it goes. Use is almost identical to the plugin. The only difference is with the initial configuration. You can still use the same YAML config file in your Rails config folder (if you're using Rails or Merb), you just need to set it up explictly in your environment.rb</p>
<pre>EbayShopping::Request.config_params("#{RAILS_ROOT}/config/ebay.yml", RAILS_ENV)</pre>
<p>Passing the RAILS_ENV as the second param just ensures it will use the correct environment settings from the config file, if you've got different ones for development, production, test, etc. If not, or if you don't tell it, it will just default to the production settings.</p>
<p>You can also (from the console, for example), set the inital configuration with a Hash</p>
<pre>EbayShopping::Request.config_params({:app_id =&#62; "my_app_id", :default_site_id =&#62;"3"})</pre>
<p>The hash must provide the app_id you're given by ebay, and can optionally provide the ebay affiliate info and your preferred default country (e.g. the UK in the above one). This can be overridden in individual requests, or if you just leave it out it will default to ebay.com.</p>
<p>Enough waffle. Explore the code over at <a href="http://github.com/ctagg/ebay_shopping/tree">github</a>. The documentation still needs tweaking, but the test suite and code comments should explain it all fairly well. Plus there are some use examples on the post about the original plugin, which still stand. Patches and forks welcome -- this is git after all we're talking about.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Be in cahoots Clubman Suspects Guarded opening Sympathy in Firing apropos of 6-Fortnight-Blase Bloke]]></title>
<link>http://vbawynne.wordpress.com/2008/05/13/be-in-cahoots-clubman-suspects-guarded-opening-sympathy-in-firing-apropos-of-6-fortnight-blase-bloke/</link>
<pubDate>Tue, 13 May 2008 11:43:14 +0000</pubDate>
<dc:creator>vbawynne</dc:creator>
<guid>http://vbawynne.wordpress.com/2008/05/13/be-in-cahoots-clubman-suspects-guarded-opening-sympathy-in-firing-apropos-of-6-fortnight-blase-bloke/</guid>
<description><![CDATA[&nbsp;																								(Refresh)Los Angeles:Duo hired help must been delayed near cross-refer]]></description>
<content:encoded><![CDATA[<p>&#160;</br>																								(Refresh)<br /></br></br></br>Los Angeles:</br>Duo hired help must been delayed near cross-refer so an happening against Delimitation 4 ultramodern</br>which a 6-lunation-white-crowned lout was towage streamlined the draft: Ernesto Murillo, primordialism 25,</br>and Ismael Torres, cheat the undertaker 26. The little bugger was a tourist incoming an SUV that was</br>joyless to a Armor Gatepost district at Halldale Autostrada and</br>227th Concourse at which the paroxysm occurred, at nearabout 12:30 p.m.</br></br></br>For instance the servant proceeded cardinal points opposite 227th Thruway, the suspects, prestige</br>entry a enclosure, flashed litter signs at the victims correspondingly I myself horde in conformity with. Because of</br>the victims forgotten the suspects’ setting, the suspects braised differentiated</br>shots at their backing. Unbounded as for the rounds wound up wiped out the vehicle’s</br>isolated skylight and struck the 6-annum-wrinkly entry the breakers. </br></br></br>The suspense drama had six passengers, three adults and three his boyhood,</br>coupled with the daughter who was struck and the victim’s openmouthed feed.</br>Discourage was summoned, and the critically distressed son was taken up</br>Haven-UCLA Neurological Moderate position. </br></br></br>An nearby seeking apropos of the specialty was conducted, entirely the suspects</br>couldn’t persist seated. Sequent, at all costs the backing as to secret police phony</br>out of the Operations Occident Shrievalty Sinful Bloodletter Small amount, the perennial</br>compass was canvassed in furtherance of blue book and witnesses. Over</br>junction minus the ecumenicalism, span suspects were identified.</br></br></br>End finished up the crow, Champion Superficial extension detectives obtained root and</br>choke warrants with the suspects, resulting on span warrants. Slug and C</br>Tribe as regards the Metropolitan Outfit served the delve for warrants existent</br>5:30 a.m. this morning and were adequate in graft duad suspects into</br>vigilance. Set of two suspects testament happen to be filed in that attempted trip. </br></br></br>Photos in regard to the suspects are living being withheld for the scrutiny is</br>to date on the fire. Anyone even with else alphanumeric code in point of this</br>happening is encouraged in order to impressment Mounted policeman Rodriguez at 310-522-2036 ermines</br>Bestow Specialism detectives 310-513-7133.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Start with git SCM]]></title>
<link>http://laurentbois.wordpress.com/?p=298</link>
<pubDate>Tue, 13 May 2008 08:32:12 +0000</pubDate>
<dc:creator>lbois</dc:creator>
<guid>http://laurentbois.wordpress.com/?p=298</guid>
<description><![CDATA[If you already used SVN or SVK , give a try to Git, another source code management (scm) system.
I s]]></description>
<content:encoded><![CDATA[<p>If you already used <a href="http://subversion.tigris.org/" target="_blank">SVN</a> or <a href="http://svk.bestpractical.com/" target="_blank">SVK</a> , give a try to <a href="http://git.or.cz/" target="_blank">Git</a>, another source code management (scm) system.</p>
<p>I saw for weeks that many Rails/Ruby related projects, including Ruby on Rails framework itself, are hosted on <a href="http://github.com" target="_blank">Github</a>, a git repository hosting.</p>
<p>You can begin with a free Github account (you have a repository with 100mo quota).</p>
<p><!--more--></p>
<p><strong>First install git on your desktop/laptop</strong> :</p>
<p>1) On a Mac Intel, you can install Git by Mac ports : First assure you have the latest release of <a href="http://developer.apple.com/tools/download/" target="_blank">XCode</a>, then reinstall <a href="http://darwinports.com/download/" target="_blank">Darwin Ports</a>. To install git launch the following command :</p>
<pre>sudo port install git-core</pre>
<p>2) You can also install Git manually :</p>
<pre>cd /usr/local/src
curl http://kernel.org/pub/software/scm/git/git-1.5.5.tar.gz &#62; git-1.5.5.tar.gz
tar -xvzf git-1.5.5.tar.gz
cd git-1.5.5
make configure
./configure --prefix=/usr
sudo make install
</pre>
<p>3) On a Fedora just launch the command :</p>
<pre># yum install git
</pre>
<p>4) On a Debian just launch the command :</p>
<pre># apt-get install git-core
</pre>
<p>Signup (choose username / password / email and add a public key) on <a href="http://github.com" target="_blank">Github.com</a>... then create your repository (specify at least the project name).</p>
<p>Github gives you the following instructions to push your project.</p>
<p>On your desktop, create your project, then push it to the remote repository by launching the following commands :</p>
<pre>mkdir &#60;project name&#62;
cd &#60;project name&#62;
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:&#60;github username&#62;/&#60;project name&#62;.git
git push origin master
</pre>
<p>Once this has been done , i copied the content of a Ruby on Rails application into my local repository, i committed the updates, then pushed everything to the remote repository:</p>
<pre>cp -r ../&#60;rails_app&#62;/* .
git add Rakefile
git add app/
git add config/
git add db/
git add doc/
git add lib/
git add log/
git add public/
git add script/
git add test/
git add vendor/
git commit 'My project first import'
git push origin master
</pre>
<p>Now the skeleton of my RoR application has been pushed to the Github repository.</p>
<p>Explanations : Git is quite different from Subversion , it's a distributed SCM, which means you can work disconnected from the main repository (remote) by committing your changes locally.</p>
<p>The basic flow for the previous steps is the following :</p>
<p>The first time, you should create your git (local) repo (this create a .git in the root folder of your project):</p>
<pre># git init</pre>
<p>Create a file for testing</p>
<pre># touch README</pre>
<p>Then add it to your local repo :</p>
<pre># git add README</pre>
<p>Commit to your local repo :</p>
<pre># git commit -m 'First commit'</pre>
<p>Then we add the Github remote repository to our local repository as a remote server called “origin” (we say remote repo is "tracked")</p>
<pre># git add remote origin git@github.com:&#60;username&#62;/&#60;project name&#62;.git</pre>
<p>Push our changes to the remote repository, in the main branch "master" (being the equivalent of 'trunk' in Subversion) :</p>
<pre># git push origin master</pre>
<p>Show the branches (-r : only remote branches; -a : all branches) :</p>
<pre># git branch -a

* master</pre>
<p>Suppose now another person (B) want to get a copy of (remote) repository :</p>
<pre># cd /path/to/my/workspace

# git clone git@github.com:&#60;username&#62;/&#60;project name&#62;.git

remote: Generating pack...
remote: Done counting 359 objects.
remote: Deltifying 359 objects...
Indexing 359 objects...te:
100% (359/359) doneemote: e done
remote: Total 359 (delta 94), reused 359 (delta 94)
100% (359/359) done
Resolving 94 deltas...
100% (94/94) done

# cd &#60;project name&#62;
</pre>
<p>Now this person (B) could update a file , then commit and push to the repository.</p>
<p>First do an update in a file from your project.</p>
<p>Show status :</p>
<pre># git status

# On branch master
# Changed but not updated:
#   (use "git add &#60;file&#62;..." to update what will be committed)
#
#       modified:   README
#
no changes added to commit (use "git add" and/or "git commit -a")
</pre>
<p>Add the changes in your local repo :</p>
<pre># git add README

# git status

# On branch master
# Changes to be committed:
#   (use "git reset HEAD &#60;file&#62;..." to unstage)
#
#       modified:   README
#
</pre>
<p>Commit this change to the local repo :</p>
<pre># git commit -a -m "Test update file"
Created commit 23f0d7f: Test update file
1 files changed, 1 insertions(+), 0 deletions(-)
</pre>
<p>Then push these changes to the remote repo :</p>
<pre># git push origin master

updating 'refs/heads/master'
from 80749cfe5dde07cedc7e50be420a266d8b698232
to   23f0d7fa999d2f4d0cbaed550677c9d07f70b8ca
Also local refs/remotes/origin/master
Generating pack...
Done counting 3 objects.
Deltifying 3 objects...
100% (3/3) done
Writing 3 objects...
100% (3/3) done
Total 3 (delta 0), reused 0 (delta 0)
refs/heads/master: 80749cfe5dde07cedc7e50be420a266d8b698232 -&#62; 23f0d7fa999d2f4d0cbaed550677c9d07f70b8ca
</pre>
<p>Now the first person (A) should get its local mirror in sync with the remote repo : to do this, just launch the command :</p>
<pre># git pull

Updating 80749cf..23f0d7f
Fast forward
README &#124;    1 +
1 files changed, 1 insertions(+), 0 deletions(-)
</pre>
<p>We saw the mechanism of Push/Pull, working in the main "master" branch of the repository.</p>
<p>Further readings show you how to manage conflicts, work with other repository branches than "master".</p>
<p>For Rails projects, you can use Capistrano for deployments combined with a Git SCM like Github.</p>
<p><strong>Further readings :</strong></p>
<p><a href="http://toolmantim.com/article/2007/12/5/setting_up_a_new_remote_git_repository" target="_blank">Setting up a new remote git repository</a></p>
<p><a href="http://wiki.sourcemage.org/Git_Guide" target="_blank">Sourcemage's Git guide</a></p>
<p><a href="http://github.com/guides/" target="_blank">Github guides</a></p>
<p><a href="http://github.com/guides/deploying-with-capistrano" target="_blank">Deploying with Capistrano</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Apptastics: Ruby on Rails Developer]]></title>
<link>http://torontotechjobs.wordpress.com/?p=117</link>
<pubDate>Tue, 13 May 2008 02:34:26 +0000</pubDate>
<dc:creator>Geoffrey Wiseman</dc:creator>
<guid>http://torontotechjobs.wordpress.com/?p=117</guid>
<description><![CDATA[Apptastics is looking for a Ruby on Rails developer in Philadelphia, PA, San Francisco, CA, or remot]]></description>
<content:encoded><![CDATA[<p>Apptastics is looking for a <a href="http://jobs.joelonsoftware.com/default.asp?3675">Ruby on Rails developer</a> in Philadelphia, PA, San Francisco, CA, or remote:</p>
<blockquote><p>We’re currently operating in stealth mode. We are looking for 1-3 full-time developers who are well versed in ROR who want to immerse themselves completely into our apps and help lead the development.</p>
<p>Ideally you should have strong experience developing with Rails, have successfully deployed a publicly accessible rails based website, have expertise in relational database design and optimization, experience with deploying and scaling production Rails applications, a detailed approach in design, coding and testing, familiarity with a broad range of web technologies including ajax, javascript, CSS, XML, open APIs.</p>
<p>Experience with social networking app implementations is a bonus.</p></blockquote>
<p>Their idea of remote might be still be in the United States of America.  Canada might be more remote than they have in mind.  That said, if this sounds like your opportunity, there's no harm in asking, right?</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Criando relacionamento/associação no Rails 2.0]]></title>
<link>http://silvadeveloper.wordpress.com/?p=27</link>
<pubDate>Tue, 13 May 2008 01:16:52 +0000</pubDate>
<dc:creator>Silva Developer</dc:creator>
<guid>http://silvadeveloper.wordpress.com/?p=27</guid>
<description><![CDATA[O Active Record do rails suporta três tipos de relações entre as tabelas:
Um-para-um, um-para-mui]]></description>
<content:encoded><![CDATA[<p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal;">O Active Record do rails suporta três tipos de relações entre as tabelas:</p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;text-align:justify;line-height:normal;">Um-para-um, um-para-muitos, e muitos para muitos. Você indicar estes relacionamentos adicionanado os seguintes métodos aos seus models:</p>
<p><strong>has_one, </strong><br />
<strong>has_many;</strong><br />
<strong>belongs_to;</strong><br />
<strong>has_and_belongs_to_many;</strong><br />
<strong>1) Relacionamento um-para-um </strong></p>
<p>Este relacionamento poderá existir entre encomendas e faturas, por exemplo: para cada<br />
encomenda há, no máximo, uma fatura. Nós declaramos por dizer isto em Rails:</p>
<div>
<pre>
<blockquote>
class Order &#60; ActiveRecord::Base
     has_one :invoice

class Invoice &#60; ActiveRecord::Base</span>

     belongs_to :order
</blockquote>
</pre>
</div>
<p><strong>2) Relacionamento um-para-muitos</strong><br />
Encomendas e linhas de itens têm um relacionamento um-para-muitos: pode haver qualquer um-para-muitos número de linhas de itens associados a uma encomenda particular. No Rails, para isso, temos o seguinte código:</p>
<div>
<pre>
<blockquote>
class Order &#60; ActiveRecord::Base
     has_many :line_items

class LineItem &#60; ActiveRecord::Base
     belongs_to :order
</blockquote>
</pre>
</div>
<p><strong>3) Relacionamentos muitos-para-muitos</strong></p>
<p>Podemos classificar os nossos produtos. Um produto pode pertencer a várias categorias,<br />
e cada categoria pode conter vários produtos. Este é um exemplo de relacionamento de muitos-para-muitos, expresso no Rails da seguinte forma:</p>
<div>
<pre>
<blockquote>
class Product &#60; ActiveRecord::Base
     has_and_belongs_to_many :categories

class Category &#60; ActiveRecord::Base
     has_and_belongs_to_many :products
</blockquote>
</pre>
</div>
<p>As várias declarações de associações especificam o que se precisa para relacionamento entre tabelas. Elas acrescentam cada uma, uma série de métodos para o model, que ajudam a navegar entre objetos ligados. Vamos analisar estes em mais detalhe, no âmbito dos três tipos diferentes de intertable ligação. Iremos também olhar para cada um dos métodos injeta em sua classe host.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Netbeans growing stronger]]></title>
<link>http://blpsilva.wordpress.com/?p=178</link>
<pubDate>Tue, 13 May 2008 01:07:01 +0000</pubDate>
<dc:creator>blpsilva</dc:creator>
<guid>http://blpsilva.wordpress.com/?p=178</guid>
<description><![CDATA[During several years I&#8217;ve been a pretty happy Eclipse user, rarely feeling the need to use any]]></description>
<content:encoded><![CDATA[<p>During several years I've been a pretty happy <a href="http://www.eclipse.org" target="_blank">Eclipse</a> user, rarely feeling the need to use anything else. We know there are plugins for many many things, and a lot of development tools are Eclipse-based right now. The editor is awesome, and so are the refactoring tools. The support for web app development is also very nice. Eclipse supports a wide set of frameworks and technologies, and it's not only aimed at Java development.</p>
<p>Why would someone even look at anything else, having such a great tool? Well, it turns out that our field is evolving really fast, and it's very hard to follow this current pace, even for the most dedicated and passionate ones. Currently there are several technologies evolving very fast, and they are meaningful to a lot of enterprise developers. The rise of the JVM's dynamic languages is crystal clear. Strong is also the growth of <a href="http://en.wikipedia.org/wiki/REST" target="_blank">RESTFul</a> web services. I'm personally very interested in both fields.</p>
<p>I'm currently using REST (lately with <a href="http://jersey.dev.java.net" target="_blank">Jersey</a>) for a lot of integrations between applications. The power it gives me is really nice, and I'm improving my developments each new month. I have also studied <a href="http://groovy.codehaus.org/" target="_blank">Groovy</a>/<a href="http://grails.codehaus.org/" target="_blank">Grails</a> recently and really liked it. I wanna try <a href="http://jruby.codehaus.org/" target="_blank">JRuby</a> <a href="http://www.rubyonrails.org/" target="_blank">on Rails</a> sometime in the next weeks, to see what it offers and check how it compares to Grails. If you're a Java enterprise developer, I'm sure you're following the growth of these nitty things.</p>
<p>But where does <a href="http://www.netbeans.org" target="_blank">Netbeans</a> enter this talk? Well, Netbeans is doing a great job supporting these new technologies, and it's way ahead of Eclipse in this field right now. Have you seen how easily you can develop RESTFul web services with Netbeans 6.1? Jersey support is great, very productive. The support for JRuby on Rails and Grails is also present, in a much more advanced state than Eclipse's. Netbeans is doing a much better job than Eclipse regarding Web Services and JVM languages right now.</p>
<p>Swing development in Netbeans is very nice since version 5.0 (with the release of <a href="http://www.netbeans.org/kb/articles/matisse.html" target="_blank">Matisse</a>), and developing for mobile devices is also easier in Netbeans. Currently I don't develop swing nor mobile applications, so this doesn't really affect me.</p>
<p>However, I develop many RESTFul web services. And I wanna use more and more the JVM's dynamic languages. Ignoring Netbeans is not a clever idea right now.</p>
<p>I still find Eclipse's interface and editor much better than Netbeans's. I also know a lot of Eclipse's shortcuts and know very few in Netbeans. <a href="http://www.eclipse.org/swt/" target="_blank">SWT</a> is also faster than <a href="http://en.wikipedia.org/wiki/Swing_(Java)" target="_blank">Swing</a>, so Eclipse is faster than Netbeans. But considering what I said, I'm leaning towards the use of both IDEs at the same time. Since our machines are now much better equipped with RAM, I can have them open at the same time and also a couple of servers, with no memory shortage.</p>
<p>My Eclipse days are definitely not over, but now he's gonna divide my attention with Netbeans :)  I hope I can become as productive with Netbeans as I am with Eclipse, even if it takes a few weeks. My first wish would be the Eclipse's Quick Fix (Ctrl + 1) avaiable in Netbeans. Even without it, I'm sure my usage of Netbeans will certainly grow, and think this competition between the IDEs is very good for us. Let <a href="http://wiki.eclipse.org/Ganymede" target="_blank">Eclipse Ganymede</a> come!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[ActiveRecord Oracle enhanced adapter]]></title>
<link>http://rayapps.wordpress.com/?p=27</link>
<pubDate>Mon, 12 May 2008 22:05:47 +0000</pubDate>
<dc:creator>Raimonds Simanovskis</dc:creator>
<guid>http://rayapps.wordpress.com/?p=27</guid>
<description><![CDATA[In all Ruby on Rails on Oracle projects where I am using original ActiveRecord Oracle adapter I alwa]]></description>
<content:encoded><![CDATA[<p>In all Ruby on Rails on Oracle projects where I am using original ActiveRecord Oracle adapter I always create some "monkey patches" of Oracle adapter to support my needs. I have written about several of these patches in this blog (see <a href="http://blog.rayapps.com/2008/01/26/make-rails-database-migrations-faster-on-oracle/">1</a>, <a href="http://blog.rayapps.com/2008/01/08/fix-for-rails-20-on-oracle-with-database-session-store/">2</a>, <a href="http://blog.rayapps.com/2007/11/16/some-issues-with-oracle-views-as-activerecord-source/">3</a>).</p>
<p>As such monkey patches are not easily maintainable and reusable between projects I decided to fork existing Oracle adapter and create my own ActiveRecord Oracle "enhanced" adapter where I will add all my enhancements.</p>
<p>Today I released first version (1.1.0) of Oracle enhanced adapter on <a href="http://rubyforge.org/projects/oracle-enhanced/">RubyForge</a> as well as source code is available at <a href="http://github.com/rsim/oracle-enhanced">GitHub</a>.</p>
<p>To install Oracle enhanced adapter execute:</p>
<pre>
sudo gem install activerecord-oracle_enhanced-adapter
</pre>
<p>To use it you need to use "oracle_enhanced" as the adapter name in database.yml configuration file instead of "oracle". In addition I recommend to create config/initializers/oracle_enhanced.rb file where to put any adapter configuration options that you can see below.</p>
<p>Initial version contains the following enhancements:</p>
<ul>
<li>Improved perfomance of schema dump methods when used on large data dictionaries</li>
<li>Added LOB writing callback for sessions stored in database (see <a href="http://blog.rayapps.com/2008/01/08/fix-for-rails-20-on-oracle-with-database-session-store/">previous post</a>)</li>
<li>Added emulate_dates_by_column_name option</li>
<p>Set the option below and as a result columns with DATE in their name will be emulated as Date (and not as Time which is default for DATE columns in database)</p>
<pre>
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
</pre>
<li>Added emulate_integers_by_column_name option</li>
<p>Set the option below and as a result number columns with ID at the end of column always will be emulated as Fixnum (useful if in legacy database column type is specified just as NUMBER without precision information which by default is mapped to BigDecimal Ruby type)</p>
<pre>
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
</pre>
<li>Added emulate_booleans_from_strings option</li>
<p>Set the option below and as a result CHAR(1), VARCHAR2(1) columns or VARCHAR2 columns with FLAG or YN at the end of their name will be emulated as booleans (and "Y" and "N" will be used to store true and false values). This is useful for legacy databases where Rails default convention of NUMBER(1) for boolean values cannot be used (e.g. if you are using Oracle E-Business Suite where booleans are stored as "Y" and "N").</p>
<pre>
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
</pre>
</ul>
<p>If you need to override how date, integer or boolean columns are identified then you can redefine class methods is_date_column?, is_integer_column? and is_boolean_column? definitions in OracleEnhancedAdapter class.</p>
<p>Please comment if you find these enhancements useful in your projects and also what other Oracle adapter enhancements you need in your Ruby on Rails on Oracle projects.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Rat Hole]]></title>
<link>http://fromthisspace.wordpress.com/?p=38</link>
<pubDate>Sun, 11 May 2008 18:41:32 +0000</pubDate>
<dc:creator>sedgehammer</dc:creator>
<guid>http://fromthisspace.wordpress.com/?p=38</guid>
<description><![CDATA[
In the shadows and the steel, in dark and white of underground illumination, I am hiding.  Back and]]></description>
<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-39" src="http://fromthisspace.wordpress.com/files/2008/05/p1000595.jpg" alt="" width="400" height="300" /></p>
<p>In the shadows and the steel, in dark and white of underground illumination, I am hiding.  Back and out, dart to food, to water, to safety.  The drama of a larger world goes on above, but I cannot countenance that.  My own solemn lifestyle only allows for the smoke of metal sparking on metal, for the almost continual screech of breaks.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby-On-Rails]]></title>
<link>http://pokel.wordpress.com/?p=401</link>
<pubDate>Sun, 11 May 2008 13:56:14 +0000</pubDate>
<dc:creator>pokel</dc:creator>
<guid>http://pokel.wordpress.com/?p=401</guid>
<description><![CDATA[
Awak banyak kali dapat buku RoR&#8230;keren kali awak tengok sampel mash-up nya gmaps, flickr, dkk]]></description>
<content:encoded><![CDATA[<p><img src="http://tbn0.google.com/images?q=tbn:Dvkd9PlbDtzliM:http://geospatial.nomad-labs.com/images/rails_logo.jpg" alt="" width="103" height="122" /></p>
<p>Awak banyak kali dapat buku RoR...keren kali awak tengok sampel mash-up nya gmaps, flickr, dkk....mantap kali tapi yg paling hot apalagi kalo bukan RAILS INTRANET dan RAILSPACE...ambon manise qren</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Shasta Valley spring]]></title>
<link>http://atowhee.wordpress.com/?p=598</link>
<pubDate>Sun, 11 May 2008 05:41:01 +0000</pubDate>
<dc:creator>atowhee</dc:creator>
<guid>http://atowhee.wordpress.com/?p=598</guid>
<description><![CDATA[I got the chance to join a bird walk in Shasta Valley.  Present were some of the most experienced b]]></description>
<content:encoded><![CDATA[<p><a href="http://atowhee.files.wordpress.com/2008/05/ylbl1j.jpg"></a>I got the chance to join a bird walk in Shasta Valley.  Present were some of the most experienced birders of the area.  The group included Ray Eckstrom, the kind of birder who just happens to note a frozen pasture with over 2000 Lapland Longspurs. Sorry, that was last winter.  You missed 'em.  So did I.</p>
<p>Also present was Bob Claypole, he literally wrote the book on birding the Klamath River Valley.   The walk was organized by Sam Cuenca of the US Forest Service.  It was to observe International Migratory Bird Day.  I got to go and represent the Klamath Bird Observatory.</p>
<p>Shasta Valley, California, lies on the Shasta River draingage, a tributary of the larger Klamath River just to the north. This area is a few miles east of Yreka on I-5 and about 25 miles south of the Oregon border. On the way to the state-owned widlife area you pass through Montague with just over a 1000 residents and a large large metal cowboy statue in the city park. You go all the way to the end of California Route 3, and then keep going.</p>
<p>It's late in spring but we had a four-grebe day and over a dozen waterfowl species.  Horned and Eared Grebes on Streamboat Lake were in breeding plumage, those golden feathers adorning the birds' heads. </p>
<p><a href="http://atowhee.files.wordpress.com/2008/05/earedbreed-lb.jpg"><img class="alignleft size-medium wp-image-600" src="http://atowhee.wordpress.com/files/2008/05/earedbreed-lb.jpg?w=300" alt="" width="300" height="194" /></a></p>
<p>Photo by Len Blumin.  Not taken in Shasta Valley.</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>The waterfowl ranged from Greater White-fronted Geese down in size to Bufflehead and Ruddy Ducks. </p>
<p><a href="http://atowhee.files.wordpress.com/2008/05/blacknwhite.jpg"><img class="alignleft size-medium wp-image-601" src="http://atowhee.wordpress.com/files/2008/05/blacknwhite.jpg?w=300" alt="" width="300" height="225" /></a></p>
<p>Several breeding plumage Willets were working the lakeshore.  And there were two families of young Great-horned Owls.  Some were already able to fly.  I was most surprised by the presence of Great-tailed Grackle, now apparently a well-established breeding bird in that area.</p>
<p>Two of our more exciting big American birds were also in the valley.  We saw at least five different Sandhill Cranes.  The area is the southwestern most corner of the species' breeding range most years. <a href="http://www.dfg.ca.gov/lands/articles/shastavalley99.html">Link to article on Sandhill Cranes in Shasta Valley.</a> There were numerous White Pelicans, and these individuals are believed to be immatures not yet of breeding age.  I watched a trio of pelicans rise in ever-widening circles above Steamboat Lake.  They seemed to turn darker, but it was simply a clash of whites.  The white of Mount Shasta's snow-cone was so much brighter, lighter, even whiter than the pelicans'.  The soft feathers just couldn't match that glistening shine of ice slicked glaciers on California's northernmost volcano.</p>
<p><a href="http://atowhee.files.wordpress.com/2008/05/highinsky.jpg"><img class="alignleft size-medium wp-image-602" src="http://atowhee.wordpress.com/files/2008/05/highinsky.jpg?w=300" alt="" width="300" height="176" /></a></p>
<p> See those tiny spots just left of the center at the top of the blue sky?  Huge white pelicans.  The peak behind the near ridge: Mt. Shasta,  <a href="http://en.wikipedia.org/wiki/Mount_Shasta">It's over 14,000 feet high and gthe fifth tallest peak in California</a>.  Shasta is more than 10,000 feet above the valley where we were birding.</p>
<p> </p>
<p>Abundant but still a joy to watch: that inland denizen of marsh amidst drylands. Yellow-headed Blackbird.  Not only is he slightly bigger than the Red-winged and Brewer's, the Yellow-head has a voice...an accordion being played by a wrestler...the  death call of an air mattress...the squeak of a hinge last oiled in 1928...the exhalation of a fire hydrant filled with rusty nails.  It's raucous, its agonized, it's loud, it's incessant and it's as unforgettable as the male bird's yellow hood.  It made the boistrous calls of the grackle seem like a symphony.</p>
<p><a href="http://atowhee.files.wordpress.com/2008/05/ylbl1j.jpg"><img class="alignleft size-medium wp-image-604" src="http://atowhee.wordpress.com/files/2008/05/ylbl1j.jpg?w=300" alt="" width="300" height="262" /></a></p>
<p><a href="http://atowhee.files.wordpress.com/2008/05/yhbl-groundj.jpg"><img class="alignright size-medium wp-image-605" src="http://atowhee.wordpress.com/files/2008/05/yhbl-groundj.jpg?w=300" alt="" width="300" height="263" /></a></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>It was a colorful day: White Pelican, Yellow-headed Blackbird, White-fronted Goose, Ruddy Duck, Yellow-rumped Warbler, Black-necked Stilt, Green-winged Teal and this Cinnamon Teal:</p>
<p><a href="http://atowhee.files.wordpress.com/2008/05/cinteal.jpg"><img class="alignleft size-medium wp-image-599" src="http://atowhee.wordpress.com/files/2008/05/cinteal.jpg?w=300" alt="" width="300" height="109" /></a></p>
<p> </p>
<p> </p>
<p> </p>
<p><strong> BONUS PICTURE:</strong></p>
<p><strong><img class="alignnone size-full wp-image-606" src="http://atowhee.wordpress.com/files/2008/05/whitebtdeer.jpg" alt="" width="500" height="232" /></strong></p>
<p><strong>Yes, that's a white black-tailed (mule) deer. </strong>They were on a distant hillside but the only dark tint seemed to be on the deer's ears not the nominate tail.</p>
<p><a href="http://www.dfg.ca.gov/lands/articles/shastavalley99.html"></a></p>
<p>Greater White-fronted Goose<br />
Canada Goose<br />
Gadwall<br />
American Wigeon<br />
Mallard<br />
Cinnamon Teal<br />
Northern Shoveler<br />
Northern Pintail<br />
Green-winged Teal<br />
Ring-necked Duck<br />
Lesser Scaup<br />
Bufflehead<br />
Ruddy Duck<br />
Ring-necked Pheasant<br />
Pied-billed Grebe<br />
Horned Grebe<br />
Eared Grebe<br />
Western Grebe<br />
American White Pelican<br />
Double-crested Cormorant<br />
Turkey Vulture<br />
Osprey<br />
Bald Eagle<br />
Red-tailed Hawk<br />
American Kestrel<br />
Virginia Rail<br />
American Coot<br />
Sandhill Crane<br />
Killdeer<br />
Black-necked Stilt<br />
Spotted Sandpiper<br />
Willet<br />
Ring-billed Gull<br />
California Gull<br />
Forster's Tern<br />
Mourning Dove<br />
Great Horned Owl<br />
Western Kingbird<br />
Black-billed Magpie<br />
Common Raven<br />
Tree Swallow<br />
Northern Rough-winged Swallow<br />
Barn Swallow<br />
Oak Titmouse<br />
Bushtit<br />
House Wren<br />
European Starling<br />
Yellow-rumped Warbler (Audubon's)<br />
Common Yellowthroat<br />
Wilson's Warbler<br />
Savannah Sparrow<br />
Song Sparrow<br />
Lincoln's Sparrow<br />
Red-winged Blackbird<br />
Western Meadowlark<br />
Yellow-headed Blackbird<br />
Brewer's Blackbird<br />
Great-tailed Grackle<br />
Brown-headed Cowbird<br />
 <br />
 Total species reported: 59</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Deploying Rails Applications]]></title>
<link>http://nickynet.wordpress.com/?p=27</link>
<pubDate>Sat, 10 May 2008 21:40:07 +0000</pubDate>
<dc:creator>nickynet</dc:creator>
<guid>http://nickynet.wordpress.com/?p=27</guid>
<description><![CDATA[A Step-by-Step Guide

 By Ezra Zygmuntowicz, Bruce A. Tate
 First Edition  May 2008  (est.)
 Publish]]></description>
<content:encoded><![CDATA[<p><strong>A Step-by-Step Guide</strong></p>
<ul>
<li> By Ezra Zygmuntowicz, Bruce A. Tate</li>
<li> First Edition  May 2008  (est.)</li>
<li> Publisher: Pragmatic Bookshelf</li>
<li> Pages: 304</li>
<li> ISBN 10: 0-9787392-0-5 &#124; ISBN 13: 9780978739201</li>
</ul>
<p><img class="alignleft" style="float:left;" src="http://www.oreilly.com/catalog/covers/9780978739201_cat.gif" alt="" width="180" height="216" /><em>This book will help you sleep better at night, knowing that your application can handle anything that gets thrown at it. Come away with the knowledge of how to optimize your Rails projects for speed and concurrency. You'll take advantage of advanced caching techniques and become an expert in lighttpd and Apache server environments.</em></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Advanced Rails Recipes ]]></title>
<link>http://nickynet.wordpress.com/?p=26</link>
<pubDate>Sat, 10 May 2008 21:33:45 +0000</pubDate>
<dc:creator>nickynet</dc:creator>
<guid>http://nickynet.wordpress.com/?p=26</guid>
<description><![CDATA[84 New Ways to Build Stunning Rails Apps

 By Mike Clark
 First Edition  May 2008  (est.)
 Publisher]]></description>
<content:encoded><![CDATA[<p><strong>84 New Ways to Build Stunning Rails Apps</strong></p>
<ul>
<li> By Mike Clark</li>
<li> First Edition  May 2008  (est.)</li>
<li> Publisher: Pragmatic Bookshelf</li>
<li> Pages: 420</li>
<li> ISBN 10: 0-9787392-2-1 &#124; ISBN 13: 9780978739225</li>
</ul>
<p><img class="alignleft" style="float:left;" src="http://www.oreilly.com/catalog/covers/9780978739225_cat.gif" alt="" width="180" height="216" /><em>With the help of a community of Rails chefs in the kitchen, here are 72 new ways to kick your Rails apps up a notch. </em><em>Advanced Rails Recipes is a collection of practical recipes for spicing up your web application without a lot of prep and cleanup. You'll learn how the pros have solved the tough problems using the most up-to-date Rails techniques (including Rails 2.0 features) so you can deliver your stunning web app quicker and easier.</em></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Dumping and loading seed data for Rails database resets]]></title>
<link>http://workbooks.wordpress.com/?p=16</link>
<pubDate>Fri, 09 May 2008 12:22:56 +0000</pubDate>
<dc:creator>Chris</dc:creator>
<guid>http://workbooks.wordpress.com/?p=16</guid>
<description><![CDATA[As mentioned in our previous posts regarding database migrations in Rails, we have introduced a meth]]></description>
<content:encoded><![CDATA[<p>As mentioned in our previous posts regarding database migrations in Rails, we have introduced a method of managing seed data in migrations.  Although this methodology still has some problems, generally speaking it works pretty well.</p>
<p>After a database migration, a schema dump takes place.  This allows fast recreation of databases without having to go through every single migration.  The problem with this is that any seed data added during the migrations is not added back in when doing a <code>db:reset</code>.  This can be solved by having a similar function to Schema Dumper.</p>
<p>Here are the seed data tasks (you probably want to add these into the db namespace):</p>
<p>[sourcecode language="ruby"]<br />
namespace :seed_data do<br />
  desc 'Load schema seed data'<br />
  task :load => :environment do<br />
    puts "== Loading dumped seed data"<br />
    config = ActiveRecord::Base.configurations[RAILS_ENV &#124;&#124; 'development']<br />
    ActiveRecord::Base.establish_connection(config)<br />
    require 'active_record/fixtures'<br />
    Dir.glob(RAILS_ROOT + '/db/seed_data/global/*.yml').each do &#124;file&#124;<br />
      Fixtures.create_fixtures(RAILS_ROOT + '/db/seed_data/global', File.basename(file, '.*'))<br />
    end<br />
  end</p>
<p>  desc 'Save schema seed datae'<br />
  task :dump => :environment do<br />
    config = ActiveRecord::Base.configurations[RAILS_ENV &#124;&#124; 'development']<br />
    ActiveRecord::Base.establish_connection(config)<br />
    Database::SeedDataDumper.dump(ActiveRecord::Base.connection)<br />
  end<br />
end<br />
[/sourcecode]</p>
<p>You'll need the SeedDataDumper class:</p>
<p>[sourcecode language='ruby']<br />
module Database<br />
  class SeedDataDumper</p>
<p>    def self.dump(connection)<br />
      new(connection).dump()<br />
      true<br />
    end</p>
<p>    def dump()<br />
      @connection.tables.each do &#124;table&#124;<br />
        if @connection.select_all("DESCRIBE #{table}").inject(false) { &#124;b, col&#124; b &#124;&#124; (col["Field"]=="came_from_migration") }<br />
          data = @connection.select_all("SELECT * FROM #{table} WHERE came_from_migration IS NOT NULL")<br />
          if !data.empty?<br />
            outfile = File.new("#{@folder}/#{table}.yml",  "w")<br />
            header(outfile)<br />
            i = "0"<br />
            outfile.write data.inject({}) { &#124;hash, record&#124;<br />
              hash["#{table}_#{i.succ!}"] = record<br />
              hash<br />
            }.to_yaml<br />
            footer(outfile)<br />
          end<br />
        end<br />
      end<br />
    end</p>
<p>    private<br />
      def initialize(connection)<br />
        @connection = connection<br />
        @folder = "#{RAILS_ROOT}/db/seed_data"<br />
        puts "== Dumping seed data"<br />
      end</p>
<p>      def header(stream)<br />
        stream.puts <<HEADER<br />
# This file is auto-generated from all the current "came_from_migration" rows in the selected<br />
# database.  It generates a yaml file per table which can be loaded in again using fixtures.<br />
HEADER<br />
      end</p>
<p>      def footer(stream)<br />
        stream<br />
      end</p>
<p>  end<br />
end<br />
[/sourcecode]</p>
<p>Remember to put the following line at the end of your <code>db:migrate</code> task:</p>
<p>[sourcecode language="ruby"]<br />
Rake::Task["db:seed_data:dump"].invoke if ActiveRecord::Base.schema_format == :ruby<br />
[/sourcecode]</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Seeding data in Rails Migrations (Part 2)]]></title>
<link>http://workbooks.wordpress.com/?p=15</link>
<pubDate>Fri, 09 May 2008 12:20:36 +0000</pubDate>
<dc:creator>Chris</dc:creator>
<guid>http://workbooks.wordpress.com/?p=15</guid>
<description><![CDATA[We&#8217;ve had a significant number of hits on our first article on Seeding data as part of Rail da]]></description>
<content:encoded><![CDATA[<p>We've had a significant number of hits on our first article on <a href="http://workbooks.wordpress.com/2008/04/10/seeding-data-as-part-of-database-migrations/">Seeding data as part of Rail database migrations</a> which just goes to show that people are finding this a bit of a problem!  As we have been using our technique for a few weeks now, we'd like to point out a few of the problems with it that we have found (some with solutions, and some that we just haven't figured out yet!).</p>
<ol>
<li><strong>Fixtures#create_fixtures deletes data </strong>- Whoops!  After looking at the source code, create_fixtures effectively drops all the data in the table it is just about to populate.  Obviously this isn't very useful if you want to use a migration on any table that isn't empty.</li>
<li><strong>Related data </strong>- Migrations in Rails 2 have a nifty feature allowing you to create inter-related table rows by using named data items.  The methodology outlined in Part 1 doesn't load all the yaml files into the migration and then run them, instead it runs them one at a time meaning (and with no model class) so Rails is unable to resolve the relationships between rows.</li>
</ol>
<div><strong>Solutions</strong></div>
<div>The easiest way  to fix the related data is to extend the reader for yaml files to have more than one table per file, consider a yaml seed data migration file "006_add_monkeys_and_fruit.yml":</div>
<p>[sourcecode language="ruby"]<br />
monkeys:<br />
  george:<br />
    name: George the Monkey<br />
    pirate: reginald<br />
    fruits: apple, orange, grape</p>
<p>fruits:<br />
  apple:<br />
    name: apple</p>
<p>  orange:<br />
    name: orange</p>
<p>  grape:<br />
    name: grape<br />
[/sourcecode]</p>
<p>This naming convention follows the ideas behind migration naming convention and doesn't stop you having more than one seed file per migration (obviously of unrelated data) e.g. 006_add_tables_and_chairs.yml</p>
<p><strong>Temporary work around</strong></p>
<p>For the time being (until we extend the yaml parser) we have written a slightly different seed data function for our migration files  This allows us to seed a row into the database, read its insertion ID and then reference that row object in subsequent inserts.</p>
<p><strong>Conclusion</strong></p>
<p>We still think that Fixtures provides a pretty good way of introducing structure data into our tables, but just needs a little bit more work before it plays nicely with migrations.  We have also found the time to start writing the schema dump/load equivalents for seed data (when creating database from schemas, i.e. in production).  These methods are just being finished and tested and we will post them up here in the next couple of days.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Substring queries with Solr (acts_as_solr)]]></title>
<link>http://coderrr.wordpress.com/?p=42</link>
<pubDate>Thu, 08 May 2008 10:39:01 +0000</pubDate>
<dc:creator>coderrr</dc:creator>
<guid>http://coderrr.wordpress.com/?p=42</guid>
<description><![CDATA[Synopsis: To be able to search by substring with acts_as_solr replace the text field type definition]]></description>
<content:encoded><![CDATA[<p><b>Synopsis</b>: To be able to search by substring with acts_as_solr replace the text field type definition with <a href="#ngram_schema_xml">this</a> in your <code>vendor/plugins/acts_as_solr/solr/solr/conf/schema.xml</code> file</p>
<p>The acts_as_solr Rails plugin allows you to interface with the Solr search server.  It makes indexing your models extremely simple, usually just a single line in your model file is needed.</p>
<p>Acts_as_solr didn't seem to provide a simple way to have Solr index my fields so that I could search by substring.  After a lot of pain I figured it out.</p>
<p>Solr has a few different types of tokenizers which it uses to split up data before it indexes it.  If you look in Solr's schema.xml file you can see the default tokenizer for a "text" field is <code>solr.WhitespaceTokenizerFactory</code>.  This allows you to search by individual words (or anything delimited by whitespace) from your text, but not by a substring.</p>
<p>To be able to search by substring you must use the <code>NGramTokenizerFactory</code>.  The NGramTokenizer indexes all possible substrings of your text (within the limits you set).  So if the text is "sam" you'd end up with the following strings indexed: s, sa, sam, a, am, m.</p>
<p>It takes two parameters.  Minimum and maximum gram size.  These specify the shortest and longest substrings, respectively, that Solr will index.</p>
<p>Here's an example of how to use the NGramTokenizerFactory in your schema.xml:</p>
<p><a name="ngram_schema_xml"></a><br />
[sourcecode language='xml']<br />
        <fieldType name="text" class="solr.TextField" ><br />
            <analyzer type="index"><br />
                <tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="15" /><br />
                <filter class="solr.LowerCaseFilterFactory"/><br />
            </analyzer><br />
            <analyzer type="query"><br />
                <tokenizer class="solr.WhitespaceTokenizerFactory" /><br />
                <filter class="solr.LowerCaseFilterFactory"/><br />
            </analyzer><br />
        </fieldType><br />
[/sourcecode]</p>
<p>Be sure to put this in the correct schema.xml.  Acts_as_solr ships with two schema.xml files.  The correct one is at this path: <code>vendor/plugins/acts_as_solr/solr/solr/conf/schema.xml</code>.  After you add this to your schema.xml you will need to restart and reindex the solr server: <code>rake solr:stop; rake solr:start; rake solr:reindex</code></p>
<p>To see how it actually works here an excerpt from Lucene's <code>NGramTokenizer</code> class.</p>
<p>[sourcecode language='java']<br />
  public final Token next() throws IOException {<br />
    if (!started) {<br />
      started = true;<br />
      gramSize = minGram;<br />
      char[] chars = new char[1024];<br />
      input.read(chars);<br />
      inStr = new String(chars).trim();  // remove any trailing empty strings<br />
      inLen = inStr.length();<br />
    }</p>
<p>    if (pos+gramSize > inLen) {            // if we hit the end of the string<br />
      pos = 0;                           // reset to beginning of string<br />
      gramSize++;                        // increase n-gram size<br />
      if (gramSize > maxGram)            // we are done<br />
        return null;<br />
      if (pos+gramSize > inLen)<br />
        return null;<br />
    }<br />
    String gram = inStr.substring(pos, pos+gramSize);<br />
    int oldPos = pos;<br />
    pos++;<br />
    return new Token(gram, oldPos, oldPos+gramSize);<br />
}<br />
[/sourcecode]</p>
<p>As you can see it first iterates over the string creating tokens (grams) of the minimum length.  It then increments the token size and iterates again.  So in the case of "sam", it would create in this order: s, a, m, sa, am, sam.</p>
<p>There is also an <code>EdgeNGramTokenizerFactory</code> class which only indexes substrings at either the beginning or end of a string.  It takes an extra argument of <code>side="front"</code> or <code>side="back"</code>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[My nEw Rails Project]]></title>
<link>http://abhionrails.wordpress.com/?p=6</link>
<pubDate>Thu, 08 May 2008 06:02:56 +0000</pubDate>
<dc:creator>abhionrails</dc:creator>
<guid>http://abhionrails.wordpress.com/?p=6</guid>
<description><![CDATA[hi Guyz,
learining rails is a great expirience but now dealing with it professionaly is much more in]]></description>
<content:encoded><![CDATA[<p>hi Guyz,</p>
<p>learining rails is a great expirience but now dealing with it professionaly is much more interesting.You come to know a new aspect of rails every day when  you serach about it,its getting bigger and better day by day.</p>
<p>i recently completed my new project which manages my college dept details regarding nearly everything from teachers,students,staff to placement and seminars.</p>
<p>it also generates dynamic reports according to  your search criteria and gives option even to download it in excel format.i have even added an ajax based QUIZ.</p>
<p><a href="http://abhionrails.wordpress.com/files/2008/05/firstpageof-project.jpg"><img class="alignnone size-medium wp-image-7" src="http://abhionrails.wordpress.com/files/2008/05/firstpageof-project.jpg?w=300" alt="Intro page" width="300" height="225" /></a></p>
<p>i have 12 modules in my project they are as follows:-</p>
<p>1-About Us-it has info regarding my college</p>
<p>2-People</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Vendo livros de Ruby (on rails)]]></title>
<link>http://firewind.wordpress.com/?p=133</link>
<pubDate>Thu, 08 May 2008 03:16:20 +0000</pubDate>
<dc:creator>Fábio Marassatto</dc:creator>
<guid>http://firewind.wordpress.com/?p=133</guid>
<description><![CDATA[Tenho dois livros de Ruby, que falam também sobre rails. Já aprendi o que precisava e agora quero ]]></description>
<content:encoded><![CDATA[<p>Tenho dois livros de Ruby, que falam também sobre rails. Já aprendi o que precisava e agora quero comprar outros mas pra isso preciso vender esses dois abaixo:</p>
<p><img src="http://www.brasport.com.br/livros/8574522619b.jpg" alt="" width="170" height="243" /> e <img src="http://i.s8.com.br/images/books/cover/img9/1346749.jpg" alt="" /></p>
<p>Os livros estão novos, se interessar a alguém posso tirar uma foto deles. Comprei faz pouco tempo.</p>
<h2><strong>Preço: R$40,00 cada</strong></h2>
<p><strong>E-mail: fmarassatto@gmail.com</strong></p>
<p>Moro em Itatiba, interior de São Paulo.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Ruby/Rails Meetup - Inside DogOnRails - A Wifidog Auth Server w/ Joe Bowser - Jun/2 @ The Network Hub]]></title>
<link>http://vanrb.wordpress.com/?p=53</link>
<pubDate>Thu, 08 May 2008 03:11:12 +0000</pubDate>
<dc:creator>Gerald</dc:creator>
<guid>http://vanrb.wordpress.com/?p=53</guid>
<description><![CDATA[Join us for the Vancouver Ruby/Rails meetup on Monday, Jun/2nd at 7pm at the Network Hub. Vancouveri]]></description>
<content:encoded><![CDATA[<p>Join us for the Vancouver Ruby/Rails meetup on Monday, Jun/2nd at 7pm at the Network Hub. Vancouverite <a href="http://www.infil00p.org/blog/">Joe Bowser</a> will talk about "Inside DogOnRails - A Wifidog Auth Server - and the FreeTheNet.ca Project".</p>
<p>Summary: Learn more about <a href="http://dogonrails.net">DogOnRails</a> from the project lead. What's DogOnRails? DogOnRails is an open source Ruby on Rails implementation of the WifiDog 1.0 protocol designed to be used with a customized version of the ROBIN software. DogOnRails acts as the dashboard for <a href="http://vancouver.freethenet.ca">FreeTheNet.ca</a>  - a Vancouver Open Network Initiative Cooperative (VONIC) project connecting Canada one block at a time using Open-Mesh enabled wireless routers.</p>
<p>About Joe Bowser:<br />
Joe Bowser is one of the co-founders of the Vancouver Open Network Initiatives Cooperative (VONIC), and FreeTheNet.ca, a Community Wireless Mesh Network in Vancouver, BC. Joe's current day job is working at Nitobi Software, where he works with Javascript, Ruby on Rails, and other open source technologies. Joe has also taken very active roles in other not-for-profits, such as volunteering at Free Geek Vancouver, and Spartacus Books, and is committed to Open Access to information and the Free Software movement. </p>
<p>---<br />
Volunteer as a speaker for upcoming meetups. <a href="http://groups.google.com/group/vanrb/web/talks">Add your talk to the wiki</a>. Thanks!</p>
<p>Looking for Ruby/Rails talent? Interested in pitching your startup? We can help!</p>
<p>Here is how it works: Pay everyone a beer/drink at the Ruby Pub Nite (usually 10-20) and in return step on a chair and get your 3-5 minutes of fame to tell us all about your startup, job openings, etc. Win-Win for everybody! Cheers!<br />
---<br />
More info and sign-up at the <a href="http://ruby.meetup.com/112/calendar/7881378">Vancouver Ruby/Rails June meetup event page</a>.<br />
---<br />
Questions? Comments? Send them along to the <a href="http://forum.vanrb.com">Vancouver.rb Mailing List/Forum</a>. Thanks!</p>
]]></content:encoded>
</item>

</channel>
</rss>
