<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Entendendo os contadores no Ruby on Rails</title>
	<atom:link href="http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/</link>
	<description></description>
	<lastBuildDate>Thu, 09 Feb 2012 22:10:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: juniorsatanas</title>
		<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/#comment-108288</link>
		<dc:creator>juniorsatanas</dc:creator>
		<pubDate>Wed, 01 Jul 2009 12:30:51 +0000</pubDate>
		<guid isPermaLink="false">http://simplesideias.com.br/?p=285#comment-108288</guid>
		<description>Falou tudo que eu queria saber e ninguem contava..</description>
		<content:encoded><![CDATA[<p>Falou tudo que eu queria saber e ninguem contava..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vitor Kiyoshi Arimitsu</title>
		<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/#comment-104810</link>
		<dc:creator>Vitor Kiyoshi Arimitsu</dc:creator>
		<pubDate>Sat, 18 Apr 2009 05:49:35 +0000</pubDate>
		<guid isPermaLink="false">http://simplesideias.com.br/?p=285#comment-104810</guid>
		<description>Muito bom... Tirou uma pulga atrás da minha orelha!</description>
		<content:encoded><![CDATA[<p>Muito bom... Tirou uma pulga atrás da minha orelha!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guilherme Garnier</title>
		<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/#comment-100295</link>
		<dc:creator>Guilherme Garnier</dc:creator>
		<pubDate>Sun, 11 Jan 2009 21:34:34 +0000</pubDate>
		<guid isPermaLink="false">http://simplesideias.com.br/?p=285#comment-100295</guid>
		<description>Muito bom, parabéns pelo post. Muito bem explicado.</description>
		<content:encoded><![CDATA[<p>Muito bom, parabéns pelo post. Muito bem explicado.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Entendendo os contadores no Ruby on Rails : sql</title>
		<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/#comment-100231</link>
		<dc:creator>Entendendo os contadores no Ruby on Rails : sql</dc:creator>
		<pubDate>Sat, 03 Jan 2009 20:46:46 +0000</pubDate>
		<guid isPermaLink="false">http://simplesideias.com.br/?p=285#comment-100231</guid>
		<description>[...] Leia mais deste post no blog de origem: Clique aqui e prestigie o autor [...]</description>
		<content:encoded><![CDATA[<p>[...] Leia mais deste post no blog de origem: Clique aqui e prestigie o autor [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcio Garcia</title>
		<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/#comment-100207</link>
		<dc:creator>Marcio Garcia</dc:creator>
		<pubDate>Thu, 01 Jan 2009 23:08:32 +0000</pubDate>
		<guid isPermaLink="false">http://simplesideias.com.br/?p=285#comment-100207</guid>
		<description>Show de bola Nando, no entanto, existe um pequeno problema (nao no seu código) mas como o rails trabalha com o counter caso nao seja o padrao.
Vou colocar aqui o texto com o código que mandei para os desenvolvedores do core do Rails:

Problems with :counter_cache

I found this &#039;problem&#039; (I think) when was having two self relation on the table with the same table, for instance:

Having a model like that:

create_table :codes do &#124;t&#124;
  t.string :code_key, :null =&gt; false, :limit =&gt; 25
  t.string :file_name, :null =&gt; false, :limit =&gt; 200, :default =&gt; &quot;&quot;
  t.integer :language_id, :null =&gt; false, :default =&gt; 10
  t.text :code, :null =&gt; false
  t.string :comment, :limit =&gt; 250, :default =&gt; &quot;&quot;
  t.boolean :private, :null =&gt; false, :default =&gt; false
  t.integer :reply_id
  t.integer :reply_id_count, :integer, :default =&gt; 0, :null =&gt; false
  t.timestamps
end

In the class:

# this is a self rellation....
belongs_to :reply, :class_name =&gt; &quot;Code&quot;, :foreign_key =&gt; &quot;reply_id&quot;, :counter_cache =&gt; true
  
I&#039;m willing to have with the self rellation the counter for that.
But a problem occours when I&#039;m try to make an insert:

SQLite3::SQLException: no such column: codes_count: UPDATE &quot;codes&quot; SET &quot;codes_count&quot; = COALESCE(&quot;codes_count&quot;, 0) + 1 WHERE (&quot;id&quot; = 1) 

I was surprised that the rails is trying to update a column called: &#039;codes_count&#039;, but I don&#039;t have a column with this name!
It is using the :class_name as a prefix of the collumn _count.</description>
		<content:encoded><![CDATA[<p>Show de bola Nando, no entanto, existe um pequeno problema (nao no seu código) mas como o rails trabalha com o counter caso nao seja o padrao.<br />
Vou colocar aqui o texto com o código que mandei para os desenvolvedores do core do Rails:</p>
<p>Problems with :counter_cache</p>
<p>I found this 'problem' (I think) when was having two self relation on the table with the same table, for instance:</p>
<p>Having a model like that:</p>
<p>create_table :codes do |t|<br />
  t.string :code_key, :null =&gt; false, :limit =&gt; 25<br />
  t.string :file_name, :null =&gt; false, :limit =&gt; 200, :default =&gt; ""<br />
  t.integer :language_id, :null =&gt; false, :default =&gt; 10<br />
  t.text :code, :null =&gt; false<br />
  t.string :comment, :limit =&gt; 250, :default =&gt; ""<br />
  t.boolean :private, :null =&gt; false, :default =&gt; false<br />
  t.integer :reply_id<br />
  t.integer :reply_id_count, :integer, :default =&gt; 0, :null =&gt; false<br />
  t.timestamps<br />
end</p>
<p>In the class:</p>
<p># this is a self rellation....<br />
belongs_to :reply, :class_name =&gt; "Code", :foreign_key =&gt; "reply_id", :counter_cache =&gt; true</p>
<p>I'm willing to have with the self rellation the counter for that.<br />
But a problem occours when I'm try to make an insert:</p>
<p>SQLite3::SQLException: no such column: codes_count: UPDATE "codes" SET "codes_count" = COALESCE("codes_count", 0) + 1 WHERE ("id" = 1) </p>
<p>I was surprised that the rails is trying to update a column called: 'codes_count', but I don't have a column with this name!<br />
It is using the :class_name as a prefix of the collumn _count.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nando Vieira</title>
		<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/#comment-99830</link>
		<dc:creator>Nando Vieira</dc:creator>
		<pubDate>Sun, 07 Dec 2008 00:40:26 +0000</pubDate>
		<guid isPermaLink="false">http://simplesideias.com.br/?p=285#comment-99830</guid>
		<description>Antonio, atualizei o post com um exemplo.</description>
		<content:encoded><![CDATA[<p>Antonio, atualizei o post com um exemplo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antonio</title>
		<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/#comment-99826</link>
		<dc:creator>Antonio</dc:creator>
		<pubDate>Sat, 06 Dec 2008 17:29:01 +0000</pubDate>
		<guid isPermaLink="false">http://simplesideias.com.br/?p=285#comment-99826</guid>
		<description>Muito bom! Poderia dar um exemplo simples de como utilizar essa técnica para counters dependentes de condição? por exemplo dependendo do status de &quot;thinks&quot;,

Valeu!</description>
		<content:encoded><![CDATA[<p>Muito bom! Poderia dar um exemplo simples de como utilizar essa técnica para counters dependentes de condição? por exemplo dependendo do status de "thinks",</p>
<p>Valeu!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sql &#187; Blog Archive &#187; Entendendo os contadores no Ruby on Rails</title>
		<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/#comment-99771</link>
		<dc:creator>sql &#187; Blog Archive &#187; Entendendo os contadores no Ruby on Rails</dc:creator>
		<pubDate>Thu, 04 Dec 2008 13:11:20 +0000</pubDate>
		<guid isPermaLink="false">http://simplesideias.com.br/?p=285#comment-99771</guid>
		<description>[...] Leia mais direto na fonte: simplesideias.com.br [...]</description>
		<content:encoded><![CDATA[<p>[...] Leia mais direto na fonte: simplesideias.com.br [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Claudio</title>
		<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/#comment-99751</link>
		<dc:creator>Claudio</dc:creator>
		<pubDate>Wed, 03 Dec 2008 12:52:37 +0000</pubDate>
		<guid isPermaLink="false">http://simplesideias.com.br/?p=285#comment-99751</guid>
		<description>Oi,
Achei muito interessante, rails sempre pensando num passo a frente.
Mas eu sempre fico meio com medo de usar essas propriedades de counter, pois as vezes eu não sei se ela usa exclusão mútua para essa propriedade.
Eu ainda não tive tempo de ver no código rails se ele faz exclusão mútua, vc sabe me dizer?</description>
		<content:encoded><![CDATA[<p>Oi,<br />
Achei muito interessante, rails sempre pensando num passo a frente.<br />
Mas eu sempre fico meio com medo de usar essas propriedades de counter, pois as vezes eu não sei se ela usa exclusão mútua para essa propriedade.<br />
Eu ainda não tive tempo de ver no código rails se ele faz exclusão mútua, vc sabe me dizer?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Junio Vitorino</title>
		<link>http://simplesideias.com.br/entendendo-os-contadores-no-ruby-on-rails/#comment-99729</link>
		<dc:creator>Junio Vitorino</dc:creator>
		<pubDate>Tue, 02 Dec 2008 16:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://simplesideias.com.br/?p=285#comment-99729</guid>
		<description>Muito massa e muito bem explicado como sempre, valeu Nando.</description>
		<content:encoded><![CDATA[<p>Muito massa e muito bem explicado como sempre, valeu Nando.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

