<?xml version="1.0" encoding="UTF-8"?>
<tickets type="array">
  <ticket>
    <assigned-user-id type="integer">19965</assigned-user-id>
    <attachments-count type="integer">2</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-05T15:50:45+00:00</created-at>
    <creator-id type="integer">85386</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer">27004</milestone-id>
    <number type="integer">3864</number>
    <permalink>rails-server-doesnt-start-mongrel-by-default</permalink>
    <priority type="integer">3</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>bug mongrel patch regression server</tag>
    <title>&quot;rails server&quot; doesn't start mongrel by default</title>
    <updated-at type="datetime">2010-02-09T17:05:30+00:00</updated-at>
    <user-id type="integer">27155</user-id>
    <user-name>Craig Buchek</user-name>
    <creator-name>Torsten Maul</creator-name>
    <assigned-user-name>Jos&#233; Valim</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3864</url>
    <milestone-title>3.0</milestone-title>
    <original-body>My environment: Windows XP, Ruby 1.8.7, Rails 3.0.0.beta, Mongrel gem installed

When issueing the command
@@@
rails server
@@@
 in my application path, WEBrick is started, instead of Mongrel. From looking in the documentation, there seems to be no option for setting the server. I tried with
@@@
rails server mongrel
@@@
, but that doesn't work too.

One workaround I've found, is to call
@@@
rackup --server mongrel --port 3000
@@@
in your application path.</original-body>
    <latest-body>My environment: Windows XP, Ruby 1.8.7, Rails 3.0.0.beta, Mongrel gem installed

When issueing the command
@@@
rails server
@@@
 in my application path, WEBrick is started, instead of Mongrel. From looking in the documentation, there seems to be no option for setting the server. I tried with
@@@
rails server mongrel
@@@
, but that doesn't work too.

One workaround I've found, is to call
@@@
rackup --server mongrel --port 3000
@@@
in your application path.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;My environment: Windows XP, Ruby 1.8.7, Rails 3.0.0.beta,
Mongrel gem installed&lt;/p&gt;
&lt;p&gt;When issueing the command&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;rails server&lt;/code&gt;
&lt;/pre&gt;
in my application path, WEBrick is started, instead of Mongrel.
From looking in the documentation, there seems to be no option for
setting the server. I tried with
&lt;pre&gt;
&lt;code&gt;rails server mongrel&lt;/code&gt;
&lt;/pre&gt;
, but that doesn't work too.
&lt;p&gt;One workaround I've found, is to call&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;rackup --server mongrel --port 3000&lt;/code&gt;
&lt;/pre&gt;
in your application path.&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">12714</assigned-user-id>
    <attachments-count type="integer">4</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2008-09-01T07:23:05+01:00</created-at>
    <creator-id type="integer">18566</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer">27004</milestone-id>
    <number type="integer">948</number>
    <permalink>template-lookup-should-search-controller-inheritance-chain</permalink>
    <priority type="integer">3</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>actionpack edge enhancement patch</tag>
    <title>template lookup should search controller inheritance chain</title>
    <updated-at type="datetime">2010-02-09T16:50:09+00:00</updated-at>
    <user-id type="integer">72560</user-id>
    <user-name>artemave</user-name>
    <creator-name>Caio Chassot</creator-name>
    <assigned-user-name>Yehuda Katz (wycats)</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/948</url>
    <milestone-title>3.0</milestone-title>
    <original-body>(Josh, I briefly mentioned this to you via email.)

Here's the gist of the feature:

Say you have:

  DocumentsController &lt; ApplicationController
  ArticlesController &lt; DocumentsController

and a view file at:

  app/views/documents/list.html.erb

If you request articles/list, and app/views/articles/list.html.erb doesn't exist, rails should render app/views/documents/list.html.erb for you.


Here's my plugin that implements this behavior:

http://github.com/kch/inheritable_templates/tree/master

I'm opening this case to consider making this behavior default in rails.

If you would please experiment with the plugin and let me know if the core is interested, I'd be happy to convert the plugin into a patch.</original-body>
    <latest-body>(Josh, I briefly mentioned this to you via email.)

Here's the gist of the feature:

Say you have:

  DocumentsController &lt; ApplicationController
  ArticlesController &lt; DocumentsController

and a view file at:

  app/views/documents/list.html.erb

If you request articles/list, and app/views/articles/list.html.erb doesn't exist, rails should render app/views/documents/list.html.erb for you.


Here's my plugin that implements this behavior:

http://github.com/kch/inheritable_templates/tree/master

I'm opening this case to consider making this behavior default in rails.

If you would please experiment with the plugin and let me know if the core is interested, I'd be happy to convert the plugin into a patch.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;(Josh, I briefly mentioned this to you via email.)&lt;/p&gt;
&lt;p&gt;Here's the gist of the feature:&lt;/p&gt;
&lt;p&gt;Say you have:&lt;/p&gt;
&lt;p&gt;DocumentsController &amp;lt; ApplicationController
ArticlesController &amp;lt; DocumentsController&lt;/p&gt;
&lt;p&gt;and a view file at:&lt;/p&gt;
&lt;p&gt;app/views/documents/list.html.erb&lt;/p&gt;
&lt;p&gt;If you request articles/list, and
app/views/articles/list.html.erb doesn't exist, rails should render
app/views/documents/list.html.erb for you.&lt;/p&gt;
&lt;p&gt;Here's my plugin that implements this behavior:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://github.com/kch/inheritable_templates/tree/master&quot;&gt;http://github.com/kch/inheritabl...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I'm opening this case to consider making this behavior default
in rails.&lt;/p&gt;
&lt;p&gt;If you would please experiment with the plugin and let me know
if the core is interested, I'd be happy to convert the plugin into
a patch.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">19965</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-06T12:14:54+00:00</created-at>
    <creator-id type="integer">9958</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer">27004</milestone-id>
    <number type="integer">3877</number>
    <permalink>eg-rails-server-e-test-doesnt-work-rails_envtest-rails-server-does</permalink>
    <priority type="integer">2</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>verified</state>
    <tag>initialization patch rails3 server</tag>
    <title>E.g. &quot;rails server -e test&quot; doesn't work, &quot;RAILS_ENV=test rails server&quot; does</title>
    <updated-at type="datetime">2010-02-09T14:04:06+00:00</updated-at>
    <user-id type="integer">19965</user-id>
    <user-name>Jos&#233; Valim</user-name>
    <creator-name>Henrik Nyh</creator-name>
    <assigned-user-name>Jos&#233; Valim</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3877</url>
    <milestone-title>3.0</milestone-title>
    <original-body>Looks like &quot;railties/lib/rails/commands/server.rb&quot; successfully sets RAILS_ENV to &quot;test&quot; when doing &quot;rails server -e test&quot;, but Rails.env is still set to development:

@@@ bash
henrik@Nyx ~/Sites/rails3test$ rails server -e test
=&gt; Booting WEBrick
=&gt; Rails 3.0.0.beta application starting in development on http://0.0.0.0:3000
@@@

The &quot;starting in development&quot; string uses Rails.env. I also made a controller raise Rails.env and that was &quot;development&quot;, too. So it's not just server.rb showing the wrong value.

My guess is that server.rb changes ENV['RAILS_ENV'] too late, after it's already been read for Rails.env.

It works as expected with &quot;RAILS_ENV=test rails server&quot;:

@@@ bash
henrik@Nyx ~/Sites/rails3test$ RAILS_ENV=test rails server
=&gt; Booting WEBrick
=&gt; Rails 3.0.0.beta application starting in test on http://0.0.0.0:3000
@@@

All this is on OS X.

I'll see if I can patch it, but I don't have a lot of time to spare right now.</original-body>
    <latest-body>Looks like &quot;railties/lib/rails/commands/server.rb&quot; successfully sets RAILS_ENV to &quot;test&quot; when doing &quot;rails server -e test&quot;, but Rails.env is still set to development:

@@@ bash
henrik@Nyx ~/Sites/rails3test$ rails server -e test
=&gt; Booting WEBrick
=&gt; Rails 3.0.0.beta application starting in development on http://0.0.0.0:3000
@@@

The &quot;starting in development&quot; string uses Rails.env. I also made a controller raise Rails.env and that was &quot;development&quot;, too. So it's not just server.rb showing the wrong value.

My guess is that server.rb changes ENV['RAILS_ENV'] too late, after it's already been read for Rails.env.

It works as expected with &quot;RAILS_ENV=test rails server&quot;:

@@@ bash
henrik@Nyx ~/Sites/rails3test$ RAILS_ENV=test rails server
=&gt; Booting WEBrick
=&gt; Rails 3.0.0.beta application starting in test on http://0.0.0.0:3000
@@@

All this is on OS X.

I'll see if I can patch it, but I don't have a lot of time to spare right now.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Looks like &quot;railties/lib/rails/commands/server.rb&quot; successfully
sets RAILS_ENV to &quot;test&quot; when doing &quot;rails server -e test&quot;, but
Rails.env is still set to development:&lt;/p&gt;
&lt;pre&gt;
&lt;code class=
&quot;bash&quot;&gt;henrik@Nyx ~/Sites/rails3test$ rails server -e test
=&amp;gt; Booting WEBrick
=&amp;gt; Rails 3.0.0.beta application starting in development on http://0.0.0.0:3000&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;The &quot;starting in development&quot; string uses Rails.env. I also made
a controller raise Rails.env and that was &quot;development&quot;, too. So
it's not just server.rb showing the wrong value.&lt;/p&gt;
&lt;p&gt;My guess is that server.rb changes ENV['RAILS_ENV'] too late,
after it's already been read for Rails.env.&lt;/p&gt;
&lt;p&gt;It works as expected with &quot;RAILS_ENV=test rails server&quot;:&lt;/p&gt;
&lt;pre&gt;
&lt;code class=
&quot;bash&quot;&gt;henrik@Nyx ~/Sites/rails3test$ RAILS_ENV=test rails server
=&amp;gt; Booting WEBrick
=&amp;gt; Rails 3.0.0.beta application starting in test on http://0.0.0.0:3000&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;All this is on OS X.&lt;/p&gt;
&lt;p&gt;I'll see if I can patch it, but I don't have a lot of time to
spare right now.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-09T07:24:21+00:00</created-at>
    <creator-id type="integer">27508</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3904</number>
    <permalink>bundle-group-for-addition-of-custom-irb-helpers-to-rails-console</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>3.0 console patch</tag>
    <title>bundle group for addition of custom irb helpers to rails console</title>
    <updated-at type="datetime">2010-02-09T07:24:32+00:00</updated-at>
    <user-id type="integer">27508</user-id>
    <user-name>codesnik</user-name>
    <creator-name>codesnik</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3904</url>
    <original-body>now that rails uses Bundler which loads only gems from Gemfile, your lovely .irbrc just doesn't work anymore with &quot;rails console&quot;, if you happen to load some gems there. 

There's workaround: you can remove your ~/.irbrc (it has a higher precedence) and create &quot;irbrc&quot; in Rails.root, containing just &quot;Bundler.require :console&quot;, then create group in your Gemfile

  group :console do
    gem &quot;every&quot;
    gem &quot;wirble&quot;
    ...
  end

this way you don't load thoose gems in rails server or rake tasks, but have them installed and required even in rails console on production servers, which is quite handy in small setups.

but Bundle.require :console could be added to rails console itself, just before loading IRB, and it won't hurt anybody. And then you can drop irbrc in Rails.root if thoose gems do not require additional configuration or initialization.</original-body>
    <latest-body>now that rails uses Bundler which loads only gems from Gemfile, your lovely .irbrc just doesn't work anymore with &quot;rails console&quot;, if you happen to load some gems there. 

There's workaround: you can remove your ~/.irbrc (it has a higher precedence) and create &quot;irbrc&quot; in Rails.root, containing just &quot;Bundler.require :console&quot;, then create group in your Gemfile

  group :console do
    gem &quot;every&quot;
    gem &quot;wirble&quot;
    ...
  end

this way you don't load thoose gems in rails server or rake tasks, but have them installed and required even in rails console on production servers, which is quite handy in small setups.

but Bundle.require :console could be added to rails console itself, just before loading IRB, and it won't hurt anybody. And then you can drop irbrc in Rails.root if thoose gems do not require additional configuration or initialization.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;now that rails uses Bundler which loads only gems from Gemfile,
your lovely .irbrc just doesn't work anymore with &quot;rails console&quot;,
if you happen to load some gems there.&lt;/p&gt;
&lt;p&gt;There's workaround: you can remove your ~/.irbrc (it has a
higher precedence) and create &quot;irbrc&quot; in Rails.root, containing
just &quot;Bundler.require :console&quot;, then create group in your
Gemfile&lt;/p&gt;
&lt;p&gt;group :console do&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;gem &quot;every&quot;
gem &quot;wirble&quot;
...&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;end&lt;/p&gt;
&lt;p&gt;this way you don't load thoose gems in rails server or rake
tasks, but have them installed and required even in rails console
on production servers, which is quite handy in small setups.&lt;/p&gt;
&lt;p&gt;but Bundle.require :console could be added to rails console
itself, just before loading IRB, and it won't hurt anybody. And
then you can drop irbrc in Rails.root if thoose gems do not require
additional configuration or initialization.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-08T20:03:47+00:00</created-at>
    <creator-id type="integer">9785</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3901</number>
    <permalink>patch-generator-gem-command-doesnt-accept-versions</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>bug gem generators patch</tag>
    <title>[PATCH] Generator 'gem' command doesn't accept versions</title>
    <updated-at type="datetime">2010-02-09T02:54:26+00:00</updated-at>
    <user-id type="integer">17051</user-id>
    <user-name>Adam Bair</user-name>
    <creator-name>Michael Bleigh</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3901</url>
    <original-body>In master, the `gem` command of generators will append to the Gemfile an unescaped version string. For example, with this command:

    gem 'rspec', '&gt;=2.0.0.a5'

The Gemfile will look like so at the end:

    gem &quot;rspec&quot;, &gt;=2.0.0.a5

The attached patch fixes this behavior and adds tests both for the version escaping as well as testing to make sure each gem gets its own line.</original-body>
    <latest-body>In master, the `gem` command of generators will append to the Gemfile an unescaped version string. For example, with this command:

    gem 'rspec', '&gt;=2.0.0.a5'

The Gemfile will look like so at the end:

    gem &quot;rspec&quot;, &gt;=2.0.0.a5

The attached patch fixes this behavior and adds tests both for the version escaping as well as testing to make sure each gem gets its own line.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;In master, the &lt;code&gt;gem&lt;/code&gt; command of generators will
append to the Gemfile an unescaped version string. For example,
with this command:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;gem 'rspec', '&amp;gt;=2.0.0.a5'&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;The Gemfile will look like so at the end:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;gem &quot;rspec&quot;, &amp;gt;=2.0.0.a5&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;The attached patch fixes this behavior and adds tests both for
the version escaping as well as testing to make sure each gem gets
its own line.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-01-03T17:25:20+00:00</created-at>
    <creator-id type="integer">17268</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3645</number>
    <permalink>let-label-helpers-accept-blocks</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>action_view block form_helper form_tag_helper label label_tag patch to_label_tag</tag>
    <title>Let label helpers accept blocks</title>
    <updated-at type="datetime">2010-02-08T14:56:02+00:00</updated-at>
    <user-id type="integer">17268</user-id>
    <user-name>Stephen Celis</user-name>
    <creator-name>Stephen Celis</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3645</url>
    <original-body>Label helpers should process blocks in addition to their defaults because it's common for their content to have more complex markup than text.

This, for example,
@@@
&lt;%= f.label :terms, &quot;&lt;span&gt;Accept #{link_to 'Terms', terms_path}&lt;/span&gt;&quot; %&gt;
@@@

Is much easier to read in a block
@@@
&lt;% f.label :terms do %&gt;
  &lt;span&gt;Accept &lt;%= link_to &quot;Terms&quot;, terms_path %&gt;&lt;/span&gt;
&lt;% end %&gt;
@@@

An additional perk: in our editors, the HTML markup won't be lost in Ruby string syntax highlighting.

Patch with tests in comments.</original-body>
    <latest-body>Label helpers should process blocks in addition to their defaults because it's common for their content to have more complex markup than text.

This, for example,
@@@
&lt;%= f.label :terms, &quot;&lt;span&gt;Accept #{link_to 'Terms', terms_path}&lt;/span&gt;&quot; %&gt;
@@@

Is much easier to read in a block
@@@
&lt;% f.label :terms do %&gt;
  &lt;span&gt;Accept &lt;%= link_to &quot;Terms&quot;, terms_path %&gt;&lt;/span&gt;
&lt;% end %&gt;
@@@

An additional perk: in our editors, the HTML markup won't be lost in Ruby string syntax highlighting.

Patch with tests in comments.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Label helpers should process blocks in addition to their
defaults because it's common for their content to have more complex
markup than text.&lt;/p&gt;
&lt;p&gt;This, for example,&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;&amp;lt;%= f.label :terms, &quot;&amp;lt;span&amp;gt;Accept #{link_to 'Terms', terms_path}&amp;lt;/span&amp;gt;&quot; %&amp;gt;&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Is much easier to read in a block&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;&amp;lt;% f.label :terms do %&amp;gt;
  &amp;lt;span&amp;gt;Accept &amp;lt;%= link_to &quot;Terms&quot;, terms_path %&amp;gt;&amp;lt;/span&amp;gt;
&amp;lt;% end %&amp;gt;&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;An additional perk: in our editors, the HTML markup won't be
lost in Ruby string syntax highlighting.&lt;/p&gt;
&lt;p&gt;Patch with tests in comments.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-08T11:46:52+00:00</created-at>
    <creator-id type="integer">85635</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3899</number>
    <permalink>patch-postgresql-cast-problem-on-defaultvalues</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>activerecord fix patch patched postgres postgresql schema</tag>
    <title>[PATCH] PostgreSQL CAST Problem on Defaultvalues</title>
    <updated-at type="datetime">2010-02-08T11:46:57+00:00</updated-at>
    <user-id type="integer">85635</user-id>
    <user-name>Traxanos</user-name>
    <creator-name>Traxanos</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3899</url>
    <original-body>Hi

i have a problem with PostgreSQL. PostgreSQL can cast default values and AR read the default string with cast into schema.rb.

sample:
&lt;code&gt;
CREATE TABLE soeintest
(
   test character varying NOT NULL DEFAULT '456'
);
&lt;/code&gt;
on db:
&lt;code&gt;
CREATE TABLE soeintest
(
  test character varying NOT NULL DEFAULT '456'::character varying
);
&lt;/code&gt;
in schema:
&lt;code&gt;
t.string    &quot;test&quot;,     :default =&gt; &quot;'456'::character varying&quot;, :null =&gt; false
&lt;/code&gt;
I have fix this Problem by change the SQL that read the data.</original-body>
    <latest-body>Hi

i have a problem with PostgreSQL. PostgreSQL can cast default values and AR read the default string with cast into schema.rb.

sample:
&lt;code&gt;
CREATE TABLE soeintest
(
   test character varying NOT NULL DEFAULT '456'
);
&lt;/code&gt;
on db:
&lt;code&gt;
CREATE TABLE soeintest
(
  test character varying NOT NULL DEFAULT '456'::character varying
);
&lt;/code&gt;
in schema:
&lt;code&gt;
t.string    &quot;test&quot;,     :default =&gt; &quot;'456'::character varying&quot;, :null =&gt; false
&lt;/code&gt;
I have fix this Problem by change the SQL that read the data.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;i have a problem with PostgreSQL. PostgreSQL can cast default
values and AR read the default string with cast into schema.rb.&lt;/p&gt;
&lt;p&gt;sample:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
CREATE TABLE soeintest&lt;br&gt;
( test character varying NOT NULL DEFAULT '456' );&lt;/code&gt;&lt;br&gt;
on db:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
CREATE TABLE soeintest&lt;br&gt;
( test character varying NOT NULL DEFAULT '456'::character varying
);&lt;/code&gt;&lt;br&gt;
in schema:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
t.string &quot;test&quot;, :default =&amp;gt; &quot;'456'::character varying&quot;, :null
=&amp;gt; false&lt;br&gt;&lt;/code&gt;&lt;br&gt;
I have fix this Problem by change the SQL that read the data.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">141</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-11-29T14:16:37+00:00</created-at>
    <creator-id type="integer">14798</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer">27004</milestone-id>
    <number type="integer">3518</number>
    <permalink>link_to-doesnt-escape-its-input</permalink>
    <priority type="integer">11</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>patch xss</tag>
    <title>Link_to doesn't escape its input</title>
    <updated-at type="datetime">2010-02-08T05:58:47+00:00</updated-at>
    <user-id type="integer">38796</user-id>
    <user-name>trevor</user-name>
    <creator-name>Bruno Michel</creator-name>
    <assigned-user-name>Michael Koziarski</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3518</url>
    <milestone-title>3.0</milestone-title>
    <original-body>Hi,

The link_to helper doesn't escape its first argument.

Ryan Bates has made a bug report on github for the Rails-XSS plugin (http://github.com/NZKoz/rails_xss/issues#issue/1), but I think that this problem should be fixed in Rails itself. I've attached a patch to this ticket.</original-body>
    <latest-body>Hi,

The link_to helper doesn't escape its first argument.

Ryan Bates has made a bug report on github for the Rails-XSS plugin (http://github.com/NZKoz/rails_xss/issues#issue/1), but I think that this problem should be fixed in Rails itself. I've attached a patch to this ticket.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The link_to helper doesn't escape its first argument.&lt;/p&gt;
&lt;p&gt;Ryan Bates has made a bug report on github for the Rails-XSS
plugin (&lt;a href=
&quot;http://github.com/NZKoz/rails_xss/issues#issue/1)&quot;&gt;http://github.com/NZKoz/rails_xss/issues#issue/1)&lt;/a&gt;,
but I think that this problem should be fixed in Rails itself. I've
attached a patch to this ticket.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-07T19:08:30+00:00</created-at>
    <creator-id type="integer">27133</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3886</number>
    <permalink>redundant-actionmailer-test-code-supposedly-added-to-fix-a-very-old-mocha-bug</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>patch</tag>
    <title>Redundant ActionMailer test code supposedly added to fix a very old Mocha bug</title>
    <updated-at type="datetime">2010-02-07T19:08:38+00:00</updated-at>
    <user-id type="integer">27133</user-id>
    <user-name>James Mead</user-name>
    <creator-name>James Mead</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3886</url>
    <original-body>In commit 704f2cc6dee9d55d19bfad8e4a8308fdee71bf6f a couple of lines of code were adding with the following comment: &quot;Replacing logger work around for mocha bug. Should be fixed in mocha 0.3.3&quot;.

Since the Rails Gemfile now specifies Mocha &gt;= 0.9.8 and since the ActionMailer tests still pass when these lines are removed, it seems sensible to remove them.</original-body>
    <latest-body>In commit 704f2cc6dee9d55d19bfad8e4a8308fdee71bf6f a couple of lines of code were adding with the following comment: &quot;Replacing logger work around for mocha bug. Should be fixed in mocha 0.3.3&quot;.

Since the Rails Gemfile now specifies Mocha &gt;= 0.9.8 and since the ActionMailer tests still pass when these lines are removed, it seems sensible to remove them.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;In commit 704f2cc6dee9d55d19bfad8e4a8308fdee71bf6f a couple of
lines of code were adding with the following comment: &quot;Replacing
logger work around for mocha bug. Should be fixed in mocha
0.3.3&quot;.&lt;/p&gt;
&lt;p&gt;Since the Rails Gemfile now specifies Mocha &amp;gt;= 0.9.8 and
since the ActionMailer tests still pass when these lines are
removed, it seems sensible to remove them.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">12714</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-06T22:31:20+00:00</created-at>
    <creator-id type="integer">14798</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3883</number>
    <permalink>content_tag-does-not-escape-its-input</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>3.0pre patch xss</tag>
    <title>Content_tag does not escape its input!</title>
    <updated-at type="datetime">2010-02-06T23:47:45+00:00</updated-at>
    <user-id type="integer">14798</user-id>
    <user-name>Bruno Michel</user-name>
    <creator-name>Bruno Michel</creator-name>
    <assigned-user-name>Yehuda Katz (wycats)</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3883</url>
    <original-body>Hi,

I've read http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/ and I've tried the example. Obviously, `tag` has to be remplaced by `content_tag` (error 500 else). But, the output is not the expected one, evil_js can be executed:

@@@ html
Hello &lt;strong&gt;friends&lt;/strong&gt;!
 
&lt;p&gt;&lt;script&gt;evil_js&lt;/script&gt;&lt;/p&gt;
&amp;lt;script&amp;gt;evil_js&amp;lt;/script&amp;gt;
@@@

I've tried to fix content_tag_string like this:
@@@ ruby
        def content_tag_string(name, content, options, escape = true)
          tag_options = tag_options(options, escape) if options
          &quot;&lt;#{name}#{tag_options}&gt;#{ERB::Util.h content}&lt;/#{name}&gt;&quot;.html_safe
        end 
@@@
But this breaks a lot of unit tests (184 failures in actionpack). So, I wonder if `content_tag` is really a public API that should escape its input, or if it's only for internal usage.

In the first case, it will also fix 2 others of my tickets: https://rails.lighthouseapp.com/projects/8994/tickets/3450-field_set_tag-doesnt-escape-the-legend and https://rails.lighthouseapp.com/projects/8994/tickets/3449-label-tag-doesnt-escape-its-input.</original-body>
    <latest-body>Hi,

I've read http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/ and I've tried the example. Obviously, `tag` has to be remplaced by `content_tag` (error 500 else). But, the output is not the expected one, evil_js can be executed:

@@@ html
Hello &lt;strong&gt;friends&lt;/strong&gt;!
 
&lt;p&gt;&lt;script&gt;evil_js&lt;/script&gt;&lt;/p&gt;
&amp;lt;script&amp;gt;evil_js&amp;lt;/script&amp;gt;
@@@

I've tried to fix content_tag_string like this:
@@@ ruby
        def content_tag_string(name, content, options, escape = true)
          tag_options = tag_options(options, escape) if options
          &quot;&lt;#{name}#{tag_options}&gt;#{ERB::Util.h content}&lt;/#{name}&gt;&quot;.html_safe
        end 
@@@
But this breaks a lot of unit tests (184 failures in actionpack). So, I wonder if `content_tag` is really a public API that should escape its input, or if it's only for internal usage.

In the first case, it will also fix 2 others of my tickets: https://rails.lighthouseapp.com/projects/8994/tickets/3450-field_set_tag-doesnt-escape-the-legend and https://rails.lighthouseapp.com/projects/8994/tickets/3449-label-tag-doesnt-escape-its-input.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I've read &lt;a href=
&quot;http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/&quot;&gt;http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/&lt;/a&gt;
and I've tried the example. Obviously, &lt;code&gt;tag&lt;/code&gt; has to be
remplaced by &lt;code&gt;content_tag&lt;/code&gt; (error 500 else). But, the
output is not the expected one, evil_js can be executed:&lt;/p&gt;
&lt;pre&gt;
&lt;code class=&quot;html&quot;&gt;Hello &amp;lt;strong&amp;gt;friends&amp;lt;/strong&amp;gt;!
 
&amp;lt;p&amp;gt;&amp;lt;script&amp;gt;evil_js&amp;lt;/script&amp;gt;&amp;lt;/p&amp;gt;
&amp;amp;lt;script&amp;amp;gt;evil_js&amp;amp;lt;/script&amp;amp;gt;&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;I've tried to fix content_tag_string like this:&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code class=
&quot;ruby&quot;&gt;        def content_tag_string(name, content, options, escape = true)&lt;br&gt;
&lt;br&gt;


&lt;/code&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;code class=
&quot;ruby&quot;&gt;&lt;code&gt;      tag_options = tag_options(options, escape) if options
      &amp;amp;quot;&amp;amp;lt;#{name}#{tag_options}&amp;amp;gt;#{ERB::Util.h content}&amp;amp;lt;/#{name}&amp;amp;gt;&amp;amp;quot;.html_safe
    end &amp;lt;/code&amp;gt;&lt;/code&gt;&lt;/code&gt;
&lt;/pre&gt;
&lt;pre&gt;


&lt;br&gt;
&lt;/pre&gt;
But this breaks a lot of unit tests (184 failures in actionpack).
So, I wonder if &lt;code&gt;content_tag&lt;/code&gt; is really a public API
that should escape its input, or if it's only for internal usage.
&lt;p&gt;In the first case, it will also fix 2 others of my tickets:
&lt;a href=
&quot;https://rails.lighthouseapp.com/projects/8994/tickets/3450-field_set_tag-doesnt-escape-the-legend&quot;&gt;
https://rails.lighthouseapp.com/projects/8994/tickets/3450-field_se...&lt;/a&gt;
and &lt;a href=
&quot;https://rails.lighthouseapp.com/projects/8994/tickets/3449-label-tag-doesnt-escape-its-input&quot;&gt;
https://rails.lighthouseapp.com/projects/8994/tickets/3449-label-ta...&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">6601</assigned-user-id>
    <attachments-count type="integer">2</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-06T19:10:33+00:00</created-at>
    <creator-id type="integer">26790</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3881</number>
    <permalink>patch-rails-dev-and-edge-should-bundle-install-to-vendor-not-home-or-system-gems</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>bundle patch rails vendor</tag>
    <title>[PATCH] Rails --dev and --edge should bundle install to vendor, not home or system gems</title>
    <updated-at type="datetime">2010-02-06T20:04:36+00:00</updated-at>
    <user-id type="integer">26790</user-id>
    <user-name>Kieran P</user-name>
    <creator-name>Kieran P</creator-name>
    <assigned-user-name>Carl Lerche</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3881</url>
    <original-body>Rails --dev and --edge should bundle install to vendor, not home or system gems.

This prevents altering system gems with possible buggy versions during testing of Rails edge.

Server still starts up perfectly fine with this change, and tests are passing.</original-body>
    <latest-body>Rails --dev and --edge should bundle install to vendor, not home or system gems.

This prevents altering system gems with possible buggy versions during testing of Rails edge.

Server still starts up perfectly fine with this change, and tests are passing.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Rails --dev and --edge should bundle install to vendor, not home
or system gems.&lt;/p&gt;
&lt;p&gt;This prevents altering system gems with possible buggy versions
during testing of Rails edge.&lt;/p&gt;
&lt;p&gt;Server still starts up perfectly fine with this change, and
tests are passing.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">3890</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-01-19T02:17:48+00:00</created-at>
    <creator-id type="integer">15459</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer">27004</milestone-id>
    <number type="integer">3743</number>
    <permalink>scriptplugin-install-gitwhatever-does-nothing</permalink>
    <priority type="integer">2</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>incomplete</state>
    <tag>2.3.5 3.0pre bug patch plugin scriptplugin</tag>
    <title>script/plugin install git://whatever does nothing</title>
    <updated-at type="datetime">2010-02-06T15:54:19+00:00</updated-at>
    <user-id type="integer">25293</user-id>
    <user-name>Prem Sichanugrist (sikachu)</user-name>
    <creator-name>Nate Wiger</creator-name>
    <assigned-user-name>Matt Aimonetti (mattetti)</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3743</url>
    <milestone-title>3.0</milestone-title>
    <original-body>Been this way for a while.  Borked in 2.3 and 3.0pre. Either script/plugin should be removed or it should really be fixed :-(

    [nwiger@sliver:testapp]$ script/plugin install git://github.com/fesplugas/typus.git
    Initialized empty Git repository in /Users/nwiger/Workspace/testapp/vendor/plugins/typus/.git/
    [nwiger@sliver:testapp]$ ll vendor/plugins/
    total 0
    drwxr-xr-x  3 nwiger  staff  102 Jan 18 08:09 .
    drwxr-xr-x  4 nwiger  staff  136 Jan 18 08:08 ..
    -rw-r--r--  1 nwiger  staff    0 Jan 18 08:08 .gitkeep</original-body>
    <latest-body>Been this way for a while.  Borked in 2.3 and 3.0pre. Either script/plugin should be removed or it should really be fixed :-(

    [nwiger@sliver:testapp]$ script/plugin install git://github.com/fesplugas/typus.git
    Initialized empty Git repository in /Users/nwiger/Workspace/testapp/vendor/plugins/typus/.git/
    [nwiger@sliver:testapp]$ ll vendor/plugins/
    total 0
    drwxr-xr-x  3 nwiger  staff  102 Jan 18 08:09 .
    drwxr-xr-x  4 nwiger  staff  136 Jan 18 08:08 ..
    -rw-r--r--  1 nwiger  staff    0 Jan 18 08:08 .gitkeep</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Been this way for a while. Borked in 2.3 and 3.0pre. Either
script/plugin should be removed or it should really be fixed
:-(&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;[nwiger@sliver:testapp]$ script/plugin install git://github.com/fesplugas/typus.git
Initialized empty Git repository in /Users/nwiger/Workspace/testapp/vendor/plugins/typus/.git/
[nwiger@sliver:testapp]$ ll vendor/plugins/
total 0
drwxr-xr-x  3 nwiger  staff  102 Jan 18 08:09 .
drwxr-xr-x  4 nwiger  staff  136 Jan 18 08:08 ..
-rw-r--r--  1 nwiger  staff    0 Jan 18 08:08 .gitkeep&lt;/code&gt;
&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-09-08T23:54:57+01:00</created-at>
    <creator-id type="integer">47360</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3169</number>
    <permalink>attributes-are-not-serialized-in-sti-subclasses-in-production-mode</permalink>
    <priority type="integer">139737</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>2-3-stable 2.3.4 activerecord patch serialize sti</tag>
    <title>Attributes are not serialized in STI subclasses in production mode.</title>
    <updated-at type="datetime">2010-02-05T03:26:04+00:00</updated-at>
    <user-id type="integer">85332</user-id>
    <user-name>Mike Aleksiuk</user-name>
    <creator-name>Zack Hobson</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3169</url>
    <original-body>This was originally reported and patched by Les Hill: https://rails.lighthouseapp.com/projects/8994/tickets/204

The included patch applies to v2.3.4 and fixes this issue for me, but the ticket is stale. I'm regenerating the patch and opening a new ticket in the hopes that this can be fixed in 2.3.x.

This is from his original bug report:

When using STI, if a subclass specifies that an attribute is to be serialized, and that attribute was not specified as serialized in the base class, serialization of the attribute fails.

This bug will only occur in production, not in development mode due to the class reloading in development mode.

 class Droid &lt; ActiveRecord::Base
 end

 class R2D2 &lt; Droid
   serialize :secret_message
 end

If the R2D2 class is loaded in production after the Droid class is loaded, then the serialization of the secret_message attribute will fail.</original-body>
    <latest-body>This was originally reported and patched by Les Hill: https://rails.lighthouseapp.com/projects/8994/tickets/204

The included patch applies to v2.3.4 and fixes this issue for me, but the ticket is stale. I'm regenerating the patch and opening a new ticket in the hopes that this can be fixed in 2.3.x.

This is from his original bug report:

When using STI, if a subclass specifies that an attribute is to be serialized, and that attribute was not specified as serialized in the base class, serialization of the attribute fails.

This bug will only occur in production, not in development mode due to the class reloading in development mode.

 class Droid &lt; ActiveRecord::Base
 end

 class R2D2 &lt; Droid
   serialize :secret_message
 end

If the R2D2 class is loaded in production after the Droid class is loaded, then the serialization of the secret_message attribute will fail.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;This was originally reported and patched by Les Hill: &lt;a href=
&quot;https://rails.lighthouseapp.com/projects/8994/tickets/204&quot;&gt;https://rails.lighthouseapp.com/projects/8994/tickets/204&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The included patch applies to v2.3.4 and fixes this issue for
me, but the ticket is stale. I'm regenerating the patch and opening
a new ticket in the hopes that this can be fixed in 2.3.x.&lt;/p&gt;
&lt;p&gt;This is from his original bug report:&lt;/p&gt;
&lt;p&gt;When using STI, if a subclass specifies that an attribute is to
be serialized, and that attribute was not specified as serialized
in the base class, serialization of the attribute fails.&lt;/p&gt;
&lt;p&gt;This bug will only occur in production, not in development mode
due to the class reloading in development mode.&lt;/p&gt;
&lt;p&gt;class Droid &amp;lt; ActiveRecord::Base end&lt;/p&gt;
&lt;p&gt;class R2D2 &amp;lt; Droid serialize :secret_message end&lt;/p&gt;
&lt;p&gt;If the R2D2 class is loaded in production after the Droid class
is loaded, then the serialization of the secret_message attribute
will fail.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">2</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-01-24T02:09:06+00:00</created-at>
    <creator-id type="integer">8163</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3776</number>
    <permalink>layout-lookup-fails-when-a-template-has-locale-in-its-filename</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>action_view bug i18n layouts locale patch rails3</tag>
    <title>Layout lookup fails when a template has locale in its filename</title>
    <updated-at type="datetime">2010-02-04T14:53:45+00:00</updated-at>
    <user-id type="integer">8163</user-id>
    <user-name>Eugene Pimenov</user-name>
    <creator-name>Eugene Pimenov</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3776</url>
    <original-body>In Rails3 I get an error when trying to render a template with locale in its filename. 

The repro code is (copied from the attached test):
    class WithLocaleInTemplate &lt; Base
      layout &quot;hello&quot;

      def index
        render 'hello_world'
      end
    end

hello_world, for example, is hello_world.en.html.erb

Exception I get:
      NoMethodError: You specified nil as the layout, but no such method was found
          rails/actionpack/lib/abstract_controller/layouts.rb:397:in `_default_layout'

 Actual exception is
     undefined method `|' for :en:Symbol
     rails/actionpack/lib/action_view/template/resolver.rb:15:in `register_detail'
     rails/actionpack/lib/action_view/template/resolver.rb:59:in `call'
     rails/actionpack/lib/action_view/template/resolver.rb:59:in `normalize_detail'

but it's hidden behind rescue NoMethodError in _default_layout.

The fix is one-liner:
      -        locale  = details.last &amp;&amp; details.pop.to_sym
      +        locale  = details.last &amp;&amp; [details.pop.to_sym]</original-body>
    <latest-body>In Rails3 I get an error when trying to render a template with locale in its filename. 

The repro code is (copied from the attached test):
    class WithLocaleInTemplate &lt; Base
      layout &quot;hello&quot;

      def index
        render 'hello_world'
      end
    end

hello_world, for example, is hello_world.en.html.erb

Exception I get:
      NoMethodError: You specified nil as the layout, but no such method was found
          rails/actionpack/lib/abstract_controller/layouts.rb:397:in `_default_layout'

 Actual exception is
     undefined method `|' for :en:Symbol
     rails/actionpack/lib/action_view/template/resolver.rb:15:in `register_detail'
     rails/actionpack/lib/action_view/template/resolver.rb:59:in `call'
     rails/actionpack/lib/action_view/template/resolver.rb:59:in `normalize_detail'

but it's hidden behind rescue NoMethodError in _default_layout.

The fix is one-liner:
      -        locale  = details.last &amp;&amp; details.pop.to_sym
      +        locale  = details.last &amp;&amp; [details.pop.to_sym]</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;In Rails3 I get an error when trying to render a template with
locale in its filename.&lt;/p&gt;
&lt;p&gt;The repro code is (copied from the attached test):&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;class WithLocaleInTemplate &amp;lt; Base
  layout &quot;hello&quot;

  def index
    render 'hello_world'
  end
end&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;hello_world, for example, is hello_world.en.html.erb&lt;/p&gt;
&lt;p&gt;Exception I get:&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;  NoMethodError: You specified nil as the layout, but no such method was found
      rails/actionpack/lib/abstract_controller/layouts.rb:397:in `_default_layout'&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Actual exception is&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt; undefined method `|' for :en:Symbol
 rails/actionpack/lib/action_view/template/resolver.rb:15:in `register_detail'
 rails/actionpack/lib/action_view/template/resolver.rb:59:in `call'
 rails/actionpack/lib/action_view/template/resolver.rb:59:in `normalize_detail'&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;but it's hidden behind rescue NoMethodError in
_default_layout.&lt;/p&gt;
&lt;p&gt;The fix is one-liner:&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;  -        locale  = details.last &amp;amp;&amp;amp; details.pop.to_sym
  +        locale  = details.last &amp;amp;&amp;amp; [details.pop.to_sym]&lt;/code&gt;
&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">141</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-03T17:22:44+00:00</created-at>
    <creator-id type="integer">12871</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3842</number>
    <permalink>overwrite-type-attribute-for-text_field-patch</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>email helper patch text_field url</tag>
    <title>Overwrite type attribute for text_field [PATCH]</title>
    <updated-at type="datetime">2010-02-03T17:22:47+00:00</updated-at>
    <user-id type="integer">12871</user-id>
    <user-name>Yves Vogl</user-name>
    <creator-name>Yves Vogl</creator-name>
    <assigned-user-name>Michael Koziarski</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3842</url>
    <original-body>Hi,

I added the ability to overwrite the type attribute of the text_field helper to e.g. allow creating input fields with type &quot;email&quot; and &quot;url&quot;. I decided not to separate those like the ones for &quot;hidden&quot;, &quot;password&quot; because it seems that this attributes aren't W3C standard, yet. I added them because they ease the pain on iPhone when entering such information.</original-body>
    <latest-body>Hi,

I added the ability to overwrite the type attribute of the text_field helper to e.g. allow creating input fields with type &quot;email&quot; and &quot;url&quot;. I decided not to separate those like the ones for &quot;hidden&quot;, &quot;password&quot; because it seems that this attributes aren't W3C standard, yet. I added them because they ease the pain on iPhone when entering such information.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I added the ability to overwrite the type attribute of the
text_field helper to e.g. allow creating input fields with type
&quot;email&quot; and &quot;url&quot;. I decided not to separate those like the ones
for &quot;hidden&quot;, &quot;password&quot; because it seems that this attributes
aren't W3C standard, yet. I added them because they ease the pain
on iPhone when entering such information.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-02T22:00:35+00:00</created-at>
    <creator-id type="integer">34876</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3839</number>
    <permalink>when-specifying-public-cache-control-also-specify-max-age</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>2.3.x actionpack action_pack caching patch</tag>
    <title>When specifying public Cache-Control, also specify max-age</title>
    <updated-at type="datetime">2010-02-03T16:53:32+00:00</updated-at>
    <user-id type="integer">34876</user-id>
    <user-name>Bill Kirtley</user-name>
    <creator-name>Bill Kirtley</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3839</url>
    <original-body>The ActionController stale? and fresh_when functions will take a :public option, which will cause emission of a Cache-Control header with a public attribute.

Proxy caches will likely interpret a &quot;Cache-Control: public&quot; header to mean that the resource will never change, and will cache it forever.

If you're using either stale? or fresh_when, it's probably because the controlled resource does change over time, so you want to specify a max-age directive in the Cache-Control header to tell the proxy cache how long to serve the resource before asking the origin if it's changed.

Use of expires_in does set the max-age, and it is a workaround for this problem, but it feels awkward to have to do both.

Adding a :max_age option to fresh_when would deal with this nicely</original-body>
    <latest-body>The ActionController stale? and fresh_when functions will take a :public option, which will cause emission of a Cache-Control header with a public attribute.

Proxy caches will likely interpret a &quot;Cache-Control: public&quot; header to mean that the resource will never change, and will cache it forever.

If you're using either stale? or fresh_when, it's probably because the controlled resource does change over time, so you want to specify a max-age directive in the Cache-Control header to tell the proxy cache how long to serve the resource before asking the origin if it's changed.

Use of expires_in does set the max-age, and it is a workaround for this problem, but it feels awkward to have to do both.

Adding a :max_age option to fresh_when would deal with this nicely</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;The ActionController stale? and fresh_when functions will take a
:public option, which will cause emission of a Cache-Control header
with a public attribute.&lt;/p&gt;
&lt;p&gt;Proxy caches will likely interpret a &quot;Cache-Control: public&quot;
header to mean that the resource will never change, and will cache
it forever.&lt;/p&gt;
&lt;p&gt;If you're using either stale? or fresh_when, it's probably
because the controlled resource does change over time, so you want
to specify a max-age directive in the Cache-Control header to tell
the proxy cache how long to serve the resource before asking the
origin if it's changed.&lt;/p&gt;
&lt;p&gt;Use of expires_in does set the max-age, and it is a workaround
for this problem, but it feels awkward to have to do both.&lt;/p&gt;
&lt;p&gt;Adding a :max_age option to fresh_when would deal with this
nicely&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-02-03T01:44:28+00:00</created-at>
    <creator-id type="integer">26790</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3840</number>
    <permalink>patch-removing-some-test-warnings</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>patch tests warnings</tag>
    <title>[PATCH] Removing some test warnings</title>
    <updated-at type="datetime">2010-02-03T01:44:33+00:00</updated-at>
    <user-id type="integer">26790</user-id>
    <user-name>Kieran P</user-name>
    <creator-name>Kieran P</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3840</url>
    <original-body>Fixed some stuff to remove test warnings in active model and active support test suites. Still quite a few 'overrode method' warnings showing up (esp in ActionMailer). Not sure how to approach these.</original-body>
    <latest-body>Fixed some stuff to remove test warnings in active model and active support test suites. Still quite a few 'overrode method' warnings showing up (esp in ActionMailer). Not sure how to approach these.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Fixed some stuff to remove test warnings in active model and
active support test suites. Still quite a few 'overrode method'
warnings showing up (esp in ActionMailer). Not sure how to approach
these.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">85</assigned-user-id>
    <attachments-count type="integer">7</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2008-08-06T16:40:48+01:00</created-at>
    <creator-id type="integer">28204</creator-id>
    <milestone-due-on type="datetime">2010-01-15T00:00:00+00:00</milestone-due-on>
    <milestone-id type="integer">50064</milestone-id>
    <number type="integer">765</number>
    <permalink>primary_key-option-for-belongs_to</permalink>
    <priority type="integer">2</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>incomplete</state>
    <tag>activerecord belongs_to patch primary_key tests</tag>
    <title>PATCH: primary_key option for belongs_to </title>
    <updated-at type="datetime">2010-02-02T23:31:19+00:00</updated-at>
    <user-id type="integer">19734</user-id>
    <user-name>Andrew Selder</user-name>
    <creator-name>Shawn</creator-name>
    <assigned-user-name>Jeremy Kemper</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/765</url>
    <milestone-title>2.3.6</milestone-title>
    <original-body>Could some one add :primary_key option into belongs_to in a similar fashion like ticket 292? This option is a nice-to-have for has_many, because you can always use finder_sql to workaround it. But it is a must-to-have for belongs_to because there is no way to wrok around it. I had a quick look at the source code and added 

def owner_quoted_id 
  if @reflection.options:primary_key] 
    quote_value(@owner.send @reflection.options:primary_key])) 
  else 
    @owner.quoted_id 
  end 
end 

into belongs_to.rb. 
it didn't work</original-body>
    <latest-body>Could some one add :primary_key option into belongs_to in a similar fashion like ticket 292? This option is a nice-to-have for has_many, because you can always use finder_sql to workaround it. But it is a must-to-have for belongs_to because there is no way to wrok around it. I had a quick look at the source code and added 

def owner_quoted_id 
  if @reflection.options:primary_key] 
    quote_value(@owner.send @reflection.options:primary_key])) 
  else 
    @owner.quoted_id 
  end 
end 

into belongs_to.rb. 
it didn't work</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;
Could some one add :primary_key option into belongs_to in a similar fashion like ticket 292? This option is a nice-to-have for has_many, because you can always use finder_sql to workaround it. But it is a must-to-have for belongs_to because there is no way to wrok around it. I had a quick look at the source code and added
&lt;/p&gt;&lt;p&gt;
def owner_quoted_id
&lt;/p&gt;&lt;p&gt;
if @reflection.options:primary_key]
&lt;/p&gt;&lt;p&gt;
quote_value(@owner.send @reflection.options:primary_key]))
&lt;/p&gt;&lt;p&gt;
else
&lt;/p&gt;&lt;p&gt;
@owner.quoted_id
&lt;/p&gt;&lt;p&gt;
end
&lt;/p&gt;&lt;p&gt;
end
&lt;/p&gt;&lt;p&gt;
into belongs_to.rb.
&lt;/p&gt;&lt;p&gt;
it didn't work
&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">1366</assigned-user-id>
    <attachments-count type="integer">3</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-03-13T09:56:21+00:00</created-at>
    <creator-id type="integer">50150</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer">9903</milestone-id>
    <number type="integer">2227</number>
    <permalink>batches-conditions-for-each-are-applied-to-each-modelfind-within-the-each-loop</permalink>
    <priority type="integer">1418</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>2-3-stable 2.3-rc1 2.3-rc2 :conditions active_record find named_scope patch</tag>
    <title>[VERIFIED] batches: :conditions for each are applied to each Model.find within the each loop</title>
    <updated-at type="datetime">2010-02-01T20:12:39+00:00</updated-at>
    <user-id type="integer">57403</user-id>
    <user-name>Brian Armstrong</user-name>
    <creator-name>claudiob (at gmail)</creator-name>
    <assigned-user-name>Pratik</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/2227</url>
    <milestone-title>2.x</milestone-title>
    <original-body>Consider the following code:

@@@ ruby
# app/models/song.rb
class Song &lt; ActiveRecord::Base
  def self.print_pairs(name)
    Song.each(:conditions =&gt; ['name = ?', name]) do |song|
        puts song[:name]
        another_song = Song.first(:conditions =&gt; ['name &lt;&gt; ?', name])
        puts another_song[:name]
      end
    end
end
@@@

I would call it by passing a song name, and it would print out the name of the same song, and the name of another song (with a different name).
After applying patch #2201, the .each function has become .find_each

The problem that I have found is that the :conditions applied to Song.each (line 4) is also automatically applied to the Song.first (line 6), and as a consequence Song.first returns an error, since it cannot find a song that matches both conditions ['name = ?', name] and ['name &lt;&gt; ?', name].

I understand that the solution to this problem is to call the inside find as following (line 6):

@@@ ruby
another_song = Song.with_exclusive_scope { first(:conditions =&gt; ['name &lt;&gt; ?', name]) }
@@@

However it is not clear whether this is a desired behavior or rather a bug. 
In this case I have not defined any default_scope for the model Song that has to be overridden by calling with_exclusive_scope, I am just calling Song.find within a Song.each(:conditions) loop.

---

To replicate this behavior:
@@@ sh
rails music
cd music
script/generate scaffold song name:string
rake db:create
rake db:migrate
script/console
@@@

@@@ ruby
Song.create(:name =&gt; &quot;Keep The Faith&quot;)
Song.create(:name =&gt; &quot;Bed Of Roses&quot;)
class Song &lt; ActiveRecord::Base
  def self.print_pairs(name)
    Song.each(:conditions =&gt; ['name = ?', name]) do |song|
        puts song[:name]
        another_song = Song.with_exclusive_scope { first(:conditions =&gt; ['name &lt;&gt; ?', name]) }
        puts another_song[:name]
      end
    end
end
Song.print_pairs('Bed Of Roses')
@@@

Once again, the same occurs also after patch #2201, calling .find_each rather than .each, and also using a named_scope to declare the conditions.</original-body>
    <latest-body>Consider the following code:

@@@ ruby
# app/models/song.rb
class Song &lt; ActiveRecord::Base
  def self.print_pairs(name)
    Song.each(:conditions =&gt; ['name = ?', name]) do |song|
        puts song[:name]
        another_song = Song.first(:conditions =&gt; ['name &lt;&gt; ?', name])
        puts another_song[:name]
      end
    end
end
@@@

I would call it by passing a song name, and it would print out the name of the same song, and the name of another song (with a different name).
After applying patch #2201, the .each function has become .find_each

The problem that I have found is that the :conditions applied to Song.each (line 4) is also automatically applied to the Song.first (line 6), and as a consequence Song.first returns an error, since it cannot find a song that matches both conditions ['name = ?', name] and ['name &lt;&gt; ?', name].

I understand that the solution to this problem is to call the inside find as following (line 6):

@@@ ruby
another_song = Song.with_exclusive_scope { first(:conditions =&gt; ['name &lt;&gt; ?', name]) }
@@@

However it is not clear whether this is a desired behavior or rather a bug. 
In this case I have not defined any default_scope for the model Song that has to be overridden by calling with_exclusive_scope, I am just calling Song.find within a Song.each(:conditions) loop.

---

To replicate this behavior:
@@@ sh
rails music
cd music
script/generate scaffold song name:string
rake db:create
rake db:migrate
script/console
@@@

@@@ ruby
Song.create(:name =&gt; &quot;Keep The Faith&quot;)
Song.create(:name =&gt; &quot;Bed Of Roses&quot;)
class Song &lt; ActiveRecord::Base
  def self.print_pairs(name)
    Song.each(:conditions =&gt; ['name = ?', name]) do |song|
        puts song[:name]
        another_song = Song.with_exclusive_scope { first(:conditions =&gt; ['name &lt;&gt; ?', name]) }
        puts another_song[:name]
      end
    end
end
Song.print_pairs('Bed Of Roses')
@@@

Once again, the same occurs also after patch #2201, calling .find_each rather than .each, and also using a named_scope to declare the conditions.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Consider the following code:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
# app/models/song.rb
class Song &amp;lt; ActiveRecord::Base
  def self.print_pairs(name)
    Song.each(:conditions =&amp;gt; ['name = ?', name]) do |song|
        puts song[:name]
        another_song = Song.first(:conditions =&amp;gt; ['name &amp;lt;&amp;gt; ?', name])
        puts another_song[:name]
      end
    end
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I would call it by passing a song name, and it would print out
the name of the same song, and the name of another song (with a
different name). After applying patch &lt;a href=&quot;/projects/8994/tickets/2201&quot; title=&quot;Ticket #2201&quot;&gt;#2201&lt;/a&gt;, the
.each function has become .find_each&lt;/p&gt;
&lt;p&gt;The problem that I have found is that the :conditions applied to
Song.each (line 4) is also automatically applied to the Song.first
(line 6), and as a consequence Song.first returns an error, since
it cannot find a song that matches both conditions ['name = ?',
name] and ['name &amp;lt;&amp;gt; ?', name].&lt;/p&gt;
&lt;p&gt;I understand that the solution to this problem is to call the
inside find as following (line 6):&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
another_song = Song.with_exclusive_scope { first(:conditions =&amp;gt; ['name &amp;lt;&amp;gt; ?', name]) }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However it is not clear whether this is a desired behavior or
rather a bug. In this case I have not defined any default_scope for
the model Song that has to be overridden by calling
with_exclusive_scope, I am just calling Song.find within a
Song.each(:conditions) loop.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;To replicate this behavior:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;
rails music
cd music
script/generate scaffold song name:string
rake db:create
rake db:migrate
script/console
&lt;/code&gt;&lt;/pre&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
Song.create(:name =&amp;gt; &amp;quot;Keep The Faith&amp;quot;)
Song.create(:name =&amp;gt; &amp;quot;Bed Of Roses&amp;quot;)
class Song &amp;lt; ActiveRecord::Base
  def self.print_pairs(name)
    Song.each(:conditions =&amp;gt; ['name = ?', name]) do |song|
        puts song[:name]
        another_song = Song.with_exclusive_scope { first(:conditions =&amp;gt; ['name &amp;lt;&amp;gt; ?', name]) }
        puts another_song[:name]
      end
    end
end
Song.print_pairs('Bed Of Roses')
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once again, the same occurs also after patch &lt;a href=&quot;/projects/8994/tickets/2201&quot; title=&quot;Ticket #2201&quot;&gt;#2201&lt;/a&gt;,
calling .find_each rather than .each, and also using a named_scope
to declare the conditions.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">85</assigned-user-id>
    <attachments-count type="integer">2</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-02-14T03:37:27+00:00</created-at>
    <creator-id type="integer">47398</creator-id>
    <milestone-due-on type="datetime">2010-01-15T00:00:00+00:00</milestone-due-on>
    <milestone-id type="integer">50064</milestone-id>
    <number type="integer">1966</number>
    <permalink>patch-destroy-should-respect-optimistic-locking</permalink>
    <priority type="integer">5</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>lock patch</tag>
    <title>Destroy should respect optimistic locking</title>
    <updated-at type="datetime">2010-02-01T12:31:09+00:00</updated-at>
    <user-id type="integer">47398</user-id>
    <user-name>Curtis Hawthorne</user-name>
    <creator-name>Curtis Hawthorne</creator-name>
    <assigned-user-name>Jeremy Kemper</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/1966</url>
    <milestone-title>2.3.6</milestone-title>
    <original-body>Optimistic locking doesn't currently affect #destroy
calls.  This is causing me problems because my after_destroy handlers can end up using stale data.  I could also see it causing trouble if a model had some sort of 'do_not_delete' flag that was changed right after AR loaded the record.

So, it seems to me that #destroy should follow the same optimistic locking logic as updates do.  That is, add the current lock version to the WHERE clause and raise a StaleObjectError if the delete fails.

I've written a patch (with a test and updated documentation) that accomplishes this.</original-body>
    <latest-body>Optimistic locking doesn't currently affect #destroy
calls.  This is causing me problems because my after_destroy handlers can end up using stale data.  I could also see it causing trouble if a model had some sort of 'do_not_delete' flag that was changed right after AR loaded the record.

So, it seems to me that #destroy should follow the same optimistic locking logic as updates do.  That is, add the current lock version to the WHERE clause and raise a StaleObjectError if the delete fails.

I've written a patch (with a test and updated documentation) that accomplishes this.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Optimistic locking doesn't currently affect #destroy calls. This
is causing me problems because my after_destroy handlers can end up
using stale data. I could also see it causing trouble if a model
had some sort of 'do_not_delete' flag that was changed right after
AR loaded the record.&lt;/p&gt;
&lt;p&gt;So, it seems to me that #destroy should follow the same
optimistic locking logic as updates do. That is, add the current
lock version to the WHERE clause and raise a StaleObjectError if
the delete fails.&lt;/p&gt;
&lt;p&gt;I've written a patch (with a test and updated documentation)
that accomplishes this.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">85</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-12-27T23:06:43+00:00</created-at>
    <creator-id type="integer">11102</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3624</number>
    <permalink>fix-arrayto_xml-to-produce-valid-markup-when-working-with-namespaced-classes</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>activesupport bug patch to_xml</tag>
    <title>Fix Array#to_xml to produce valid markup when working with namespaced classes</title>
    <updated-at type="datetime">2010-02-01T01:17:49+00:00</updated-at>
    <user-id type="integer">84622</user-id>
    <user-name>Mark Foster</user-name>
    <creator-name>Yaroslav Markin</creator-name>
    <assigned-user-name>Jeremy Kemper</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3624</url>
    <original-body>How to reproduce: 

@@@
@records = Namespaced::Model.all
render :xml =&gt; @records.to_xml
@@@

Before:

@@@
&lt;namespaced/models&gt; 
  &lt;namespaced/model&gt; 
    &lt;!-- --&gt;
  &lt;/namespaced/model&gt; 
&lt;/namespaced/models&gt;
@@@

After:

@@@
&lt;namespaced-models&gt; 
  &lt;namespaced-model&gt; 
    &lt;!-- --&gt;
  &lt;/namespaced-model&gt; 
&lt;/namespaced-models&gt;
@@@</original-body>
    <latest-body>How to reproduce: 

@@@
@records = Namespaced::Model.all
render :xml =&gt; @records.to_xml
@@@

Before:

@@@
&lt;namespaced/models&gt; 
  &lt;namespaced/model&gt; 
    &lt;!-- --&gt;
  &lt;/namespaced/model&gt; 
&lt;/namespaced/models&gt;
@@@

After:

@@@
&lt;namespaced-models&gt; 
  &lt;namespaced-model&gt; 
    &lt;!-- --&gt;
  &lt;/namespaced-model&gt; 
&lt;/namespaced-models&gt;
@@@</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;How to reproduce:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;@records = Namespaced::Model.all
render :xml =&amp;gt; @records.to_xml&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Before:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;&amp;lt;namespaced/models&amp;gt; 
  &amp;lt;namespaced/model&amp;gt; 
    &amp;lt;!-- --&amp;gt;
  &amp;lt;/namespaced/model&amp;gt; 
&amp;lt;/namespaced/models&amp;gt;&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;After:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;&amp;lt;namespaced-models&amp;gt; 
  &amp;lt;namespaced-model&amp;gt; 
    &amp;lt;!-- --&amp;gt;
  &amp;lt;/namespaced-model&amp;gt; 
&amp;lt;/namespaced-models&amp;gt;&lt;/code&gt;
&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-01-31T09:26:19+00:00</created-at>
    <creator-id type="integer">84622</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3824</number>
    <permalink>to_xml-generates-invalid-xml-for-arrays-of-namespaced-activerecords</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>activerecord array bug patch to_xml xml</tag>
    <title>to_xml generates invalid xml for arrays of namespaced ActiveRecords</title>
    <updated-at type="datetime">2010-01-31T23:42:16+00:00</updated-at>
    <user-id type="integer">11102</user-id>
    <user-name>Yaroslav Markin</user-name>
    <creator-name>Mark Foster</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3824</url>
    <original-body>The problem is similar to the one described in:

https://rails.lighthouseapp.com/projects/8994/tickets/2723-to_xml-generates-invalid-xml-with-namespaced-activerecord

That patch applied to a single ActiveRecord with namespaces. It turns out that the same problem occurs in arrays of ActiveRecords with namespaces as well, e. g., those returned by find(:all). 

The prior patch fixed options[:root] in to_xml for ActiveRecords . However, if the ActiveRecords are in an array, then the value of options[:root] is set in in activesupport/lib/active_support/core_ext/array/conversions.rb to_xml method and passed in to activemodel/lib/active_model/serializers/xml.rb and it contains invalid xml characters. Since options[:root] is not nil, the prior patch has no effect on correcting the invalid characters in arrays of namespaced ActiveRecords.

This patch strips out the invalid characters for any classes with namespaces from the root set in the array to_xml method.</original-body>
    <latest-body>The problem is similar to the one described in:

https://rails.lighthouseapp.com/projects/8994/tickets/2723-to_xml-generates-invalid-xml-with-namespaced-activerecord

That patch applied to a single ActiveRecord with namespaces. It turns out that the same problem occurs in arrays of ActiveRecords with namespaces as well, e. g., those returned by find(:all). 

The prior patch fixed options[:root] in to_xml for ActiveRecords . However, if the ActiveRecords are in an array, then the value of options[:root] is set in in activesupport/lib/active_support/core_ext/array/conversions.rb to_xml method and passed in to activemodel/lib/active_model/serializers/xml.rb and it contains invalid xml characters. Since options[:root] is not nil, the prior patch has no effect on correcting the invalid characters in arrays of namespaced ActiveRecords.

This patch strips out the invalid characters for any classes with namespaces from the root set in the array to_xml method.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;The problem is similar to the one described in:&lt;/p&gt;
&lt;p&gt;&lt;a href=
&quot;https://rails.lighthouseapp.com/projects/8994/tickets/2723-to_xml-generates-invalid-xml-with-namespaced-activerecord&quot;&gt;
https://rails.lighthouseapp.com/projects/8994/tickets/2723-to_xml-g...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;That patch applied to a single ActiveRecord with namespaces. It
turns out that the same problem occurs in arrays of ActiveRecords
with namespaces as well, e. g., those returned by find(:all).&lt;/p&gt;
&lt;p&gt;The prior patch fixed options[:root] in to_xml for ActiveRecords
. However, if the ActiveRecords are in an array, then the value of
options[:root] is set in in
activesupport/lib/active_support/core_ext/array/conversions.rb
to_xml method and passed in to
activemodel/lib/active_model/serializers/xml.rb and it contains
invalid xml characters. Since options[:root] is not nil, the prior
patch has no effect on correcting the invalid characters in arrays
of namespaced ActiveRecords.&lt;/p&gt;
&lt;p&gt;This patch strips out the invalid characters for any classes
with namespaces from the root set in the array to_xml method.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-01-30T15:44:01+00:00</created-at>
    <creator-id type="integer">45230</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3819</number>
    <permalink>use-assert_raise-instead-of-assert_raises</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>assertions patch</tag>
    <title>Use assert_raise instead of assert_raises</title>
    <updated-at type="datetime">2010-01-30T15:44:07+00:00</updated-at>
    <user-id type="integer">45230</user-id>
    <user-name>Matt Duncan</user-name>
    <creator-name>Matt Duncan</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3819</url>
    <original-body>Ruby docs state that assert_raises will be deprecated (I assume sometime) in Ruby 1.9 in favor of assert_raise.

http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/Assertions.html#M004509


See also #1617 which cleaned everything up a little over a year ago.


The attached patch is for master, let me know if a 2.3 patch would be useful too.</original-body>
    <latest-body>Ruby docs state that assert_raises will be deprecated (I assume sometime) in Ruby 1.9 in favor of assert_raise.

http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/Assertions.html#M004509


See also #1617 which cleaned everything up a little over a year ago.


The attached patch is for master, let me know if a 2.3 patch would be useful too.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Ruby docs state that assert_raises will be deprecated (I assume
sometime) in Ruby 1.9 in favor of assert_raise.&lt;/p&gt;
&lt;p&gt;&lt;a href=
&quot;http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/Assertions.html#M004509&quot;&gt;
http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See also &lt;a href=&quot;/projects/8994/tickets/1617&quot; title=
&quot;Ticket #1617&quot;&gt;#1617&lt;/a&gt; which cleaned everything up a little over
a year ago.&lt;/p&gt;
&lt;p&gt;The attached patch is for master, let me know if a 2.3 patch
would be useful too.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-01-30T08:17:59+00:00</created-at>
    <creator-id type="integer">8163</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3817</number>
    <permalink>when-routing-creates-a-singular-resource-it-doesnt-add-itself-to-name_prefix</permalink>
    <priority type="integer">0</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>3.0 patch rails3 resource routing</tag>
    <title>When routing creates a singular resource, it doesn't add itself to name_prefix</title>
    <updated-at type="datetime">2010-01-30T08:18:04+00:00</updated-at>
    <user-id type="integer">8163</user-id>
    <user-name>Eugene Pimenov</user-name>
    <creator-name>Eugene Pimenov</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3817</url>
    <original-body>Routing code:

    resource :subscription do
      get :renew
      resources :cards
    end

Generates these routes (irrelevant parts skipped):
                  GET    /subscription/renew(.:format)          {:action=&gt;&quot;renew&quot;, :controller=&gt;&quot;subscriptions&quot;}
                  GET    /subscription/cards(.:format)          {:action=&gt;&quot;index&quot;, :controller=&gt;&quot;cards&quot;}
            cards POST   /subscription/cards(.:format)          {:action=&gt;&quot;create&quot;, :controller=&gt;&quot;cards&quot;}
         new_card GET    /subscription/cards/new(.:format)      {:action=&gt;&quot;new&quot;, :controller=&gt;&quot;cards&quot;}
        edit_card GET    /subscription/cards/:id/edit(.:format) {:action=&gt;&quot;edit&quot;, :controller=&gt;&quot;cards&quot;}

As you can see, there's no method for renew and cards methods aren't name prefixed.</original-body>
    <latest-body>Routing code:

    resource :subscription do
      get :renew
      resources :cards
    end

Generates these routes (irrelevant parts skipped):
                  GET    /subscription/renew(.:format)          {:action=&gt;&quot;renew&quot;, :controller=&gt;&quot;subscriptions&quot;}
                  GET    /subscription/cards(.:format)          {:action=&gt;&quot;index&quot;, :controller=&gt;&quot;cards&quot;}
            cards POST   /subscription/cards(.:format)          {:action=&gt;&quot;create&quot;, :controller=&gt;&quot;cards&quot;}
         new_card GET    /subscription/cards/new(.:format)      {:action=&gt;&quot;new&quot;, :controller=&gt;&quot;cards&quot;}
        edit_card GET    /subscription/cards/:id/edit(.:format) {:action=&gt;&quot;edit&quot;, :controller=&gt;&quot;cards&quot;}

As you can see, there's no method for renew and cards methods aren't name prefixed.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Routing code:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;resource :subscription do
  get :renew
  resources :cards
end&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Generates these routes (irrelevant parts skipped):&lt;br&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;              GET    /subscription/renew(.:format)          {:action=&amp;gt;&quot;renew&quot;, :controller=&amp;gt;&quot;subscriptions&quot;}
              GET    /subscription/cards(.:format)          {:action=&amp;gt;&quot;index&quot;, :controller=&amp;gt;&quot;cards&quot;}
        cards POST   /subscription/cards(.:format)          {:action=&amp;gt;&quot;create&quot;, :controller=&amp;gt;&quot;cards&quot;}
     new_card GET    /subscription/cards/new(.:format)      {:action=&amp;gt;&quot;new&quot;, :controller=&amp;gt;&quot;cards&quot;}
    edit_card GET    /subscription/cards/:id/edit(.:format) {:action=&amp;gt;&quot;edit&quot;, :controller=&amp;gt;&quot;cards&quot;}&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;As you can see, there's no method for renew and cards methods
aren't name prefixed.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">141</assigned-user-id>
    <attachments-count type="integer">5</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-09-09T22:15:07+01:00</created-at>
    <creator-id type="integer">69218</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer">27004</milestone-id>
    <number type="integer">3178</number>
    <permalink>mass-assignment-security-refactoring</permalink>
    <priority type="integer">2</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>activerecord bugmash patch</tag>
    <title>Mass Assignment Security Refactoring</title>
    <updated-at type="datetime">2010-01-30T02:10:59+00:00</updated-at>
    <user-id type="integer">69218</user-id>
    <user-name>Eric Chapweske</user-name>
    <creator-name>Eric Chapweske</creator-name>
    <assigned-user-name>Michael Koziarski</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3178</url>
    <milestone-title>3.0</milestone-title>
    <original-body>This patch provides a rewrite that is hopefully more understandable and modular than the existing code. This should allow developers and plugin authors to experiment a bit more without introducing massive security holes. E.g., it's pretty trivial to move responsibility over to a controller by including ActiveRecord::MassAssignmentSecurity and adding a couple helper methods. This is my first contribution attempt so hopefully I didn't mess up too much ;)</original-body>
    <latest-body>This patch provides a rewrite that is hopefully more understandable and modular than the existing code. This should allow developers and plugin authors to experiment a bit more without introducing massive security holes. E.g., it's pretty trivial to move responsibility over to a controller by including ActiveRecord::MassAssignmentSecurity and adding a couple helper methods. This is my first contribution attempt so hopefully I didn't mess up too much ;)</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;This patch provides a rewrite that is hopefully more
understandable and modular than the existing code. This should
allow developers and plugin authors to experiment a bit more
without introducing massive security holes. E.g., it's pretty
trivial to move responsibility over to a controller by including
ActiveRecord::MassAssignmentSecurity and adding a couple helper
methods. This is my first contribution attempt so hopefully I
didn't mess up too much ;)&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">15783</assigned-user-id>
    <attachments-count type="integer">0</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2008-09-09T18:28:28+01:00</created-at>
    <creator-id type="integer">22990</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer">9903</milestone-id>
    <number type="integer">1004</number>
    <permalink>datetime_select-to-accept-ampm-option</permalink>
    <priority type="integer">445</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>incomplete</state>
    <tag>activerecord enhancement helper patch</tag>
    <title>datetime_select to accept :ampm option</title>
    <updated-at type="datetime">2010-01-28T18:33:31+00:00</updated-at>
    <user-id type="integer">22990</user-id>
    <user-name>Yong Bakos</user-name>
    <creator-name>Yong Bakos</creator-name>
    <assigned-user-name>Geoff Buesing</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/1004</url>
    <milestone-title>2.x</milestone-title>
    <original-body>I'd like to propose the development of a patch to core that adds the capability of the datetime_select to render a 12-hour selectlist for the hour, and an am/pm selectlist.

Previous plugin/module solutions to this are old, I couldn't find anything relevant on github, and this just seems (to me) like it should belong in core.

I belive this this will also require changes to AR.

Patch to come, unless this ticket gets nixed.</original-body>
    <latest-body>I'd like to propose the development of a patch to core that adds the capability of the datetime_select to render a 12-hour selectlist for the hour, and an am/pm selectlist.

Previous plugin/module solutions to this are old, I couldn't find anything relevant on github, and this just seems (to me) like it should belong in core.

I belive this this will also require changes to AR.

Patch to come, unless this ticket gets nixed.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;I'd like to propose the development of a patch to core that adds
the capability of the datetime_select to render a 12-hour
selectlist for the hour, and an am/pm selectlist.&lt;/p&gt;
&lt;p&gt;Previous plugin/module solutions to this are old, I couldn't
find anything relevant on github, and this just seems (to me) like
it should belong in core.&lt;/p&gt;
&lt;p&gt;I belive this this will also require changes to AR.&lt;/p&gt;
&lt;p&gt;Patch to come, unless this ticket gets nixed.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">8406</assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2010-01-20T23:28:08+00:00</created-at>
    <creator-id type="integer">136</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3760</number>
    <permalink>make-ar-guess-the-inverse-of-an-association-if-not-specified</permalink>
    <priority type="integer">1</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>activerecord inverse_of patch</tag>
    <title>Make AR guess the inverse of an association if not specified</title>
    <updated-at type="datetime">2010-01-26T18:31:24+00:00</updated-at>
    <user-id type="integer">85</user-id>
    <user-name>Jeremy Kemper</user-name>
    <creator-name>Murray Steele</creator-name>
    <assigned-user-name>Eloy Duran</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3760</url>
    <original-body>Change ActiveRecord so that if the model doesn't specify an explicit :inverse_of option AR will try to guess and give the model the benefits of :inverse_of.  In some cases AR won't be able to guess, or will guess wrong, so you can still specify explcitly using :inverse_of.  You can also turn off the feature on a case by case basis if you specify :inverse_of =&gt; nil.

You might want to do this if you have validations or autosaves on your associations that might cause an infinite loop.</original-body>
    <latest-body>Change ActiveRecord so that if the model doesn't specify an explicit :inverse_of option AR will try to guess and give the model the benefits of :inverse_of.  In some cases AR won't be able to guess, or will guess wrong, so you can still specify explcitly using :inverse_of.  You can also turn off the feature on a case by case basis if you specify :inverse_of =&gt; nil.

You might want to do this if you have validations or autosaves on your associations that might cause an infinite loop.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Change ActiveRecord so that if the model doesn't specify an
explicit :inverse_of option AR will try to guess and give the model
the benefits of :inverse_of. In some cases AR won't be able to
guess, or will guess wrong, so you can still specify explcitly
using :inverse_of. You can also turn off the feature on a case by
case basis if you specify :inverse_of =&amp;gt; nil.&lt;/p&gt;
&lt;p&gt;You might want to do this if you have validations or autosaves
on your associations that might cause an infinite loop.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">1</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-11-30T07:53:52+00:00</created-at>
    <creator-id type="integer">11354</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">3521</number>
    <permalink>patch-add-conditional-counter-cache</permalink>
    <priority type="integer">179947</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>new</state>
    <tag>2-3-stable counter_cache patch</tag>
    <title>[PATCH] Add conditional counter cache</title>
    <updated-at type="datetime">2010-01-26T16:42:01+00:00</updated-at>
    <user-id type="integer">11354</user-id>
    <user-name>Scott Windsor</user-name>
    <creator-name>Scott Windsor</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/3521</url>
    <original-body>One common pattern that I keep repeating is lots of repeated code to handle cache counters based on a flag or status.  Take the example of Posts &amp; Comments.  I want a counter cache for comments, but I don't want to include ones that are deleted.  This should also take into account updates as well as creates &amp; deletes.

Here's an example of the syntax:

  belongs_to :post, :counter_cache =&gt; {:condition =&gt; lambda {|c| !c.deleted } }

This only increments or decrements the counter if the lambda returns true (and the lambda has self passed in).

I've added support for this in the following patch.  I've also included unit tests for this functionality.  This works in 2-3-stable, but I haven't tested against master.</original-body>
    <latest-body>One common pattern that I keep repeating is lots of repeated code to handle cache counters based on a flag or status.  Take the example of Posts &amp; Comments.  I want a counter cache for comments, but I don't want to include ones that are deleted.  This should also take into account updates as well as creates &amp; deletes.

Here's an example of the syntax:

  belongs_to :post, :counter_cache =&gt; {:condition =&gt; lambda {|c| !c.deleted } }

This only increments or decrements the counter if the lambda returns true (and the lambda has self passed in).

I've added support for this in the following patch.  I've also included unit tests for this functionality.  This works in 2-3-stable, but I haven't tested against master.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;One common pattern that I keep repeating is lots of repeated
code to handle cache counters based on a flag or status. Take the
example of Posts &amp;amp; Comments. I want a counter cache for
comments, but I don't want to include ones that are deleted. This
should also take into account updates as well as creates &amp;amp;
deletes.&lt;/p&gt;
&lt;p&gt;Here's an example of the syntax:&lt;/p&gt;
&lt;p&gt;belongs_to :post, :counter_cache =&amp;gt; {:condition =&amp;gt; lambda
{|c| !c.deleted } }&lt;/p&gt;
&lt;p&gt;This only increments or decrements the counter if the lambda
returns true (and the lambda has self passed in).&lt;/p&gt;
&lt;p&gt;I've added support for this in the following patch. I've also
included unit tests for this functionality. This works in
2-3-stable, but I haven't tested against master.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer">85</assigned-user-id>
    <attachments-count type="integer">5</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-08-03T22:27:35+01:00</created-at>
    <creator-id type="integer">64992</creator-id>
    <milestone-due-on type="datetime" nil="true"></milestone-due-on>
    <milestone-id type="integer" nil="true"></milestone-id>
    <number type="integer">2990</number>
    <permalink>none-standard-id-column-on-has_many-through</permalink>
    <priority type="integer">130019</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>bugmash hasmany patch primarykey review</tag>
    <title>[PATCH] Non standard ID column on has_many :through</title>
    <updated-at type="datetime">2010-01-25T17:20:40+00:00</updated-at>
    <user-id type="integer">25293</user-id>
    <user-name>Prem Sichanugrist (sikachu)</user-name>
    <creator-name>James Pearson</creator-name>
    <assigned-user-name>Jeremy Kemper</assigned-user-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/2990</url>
    <original-body>Usingthe example code below:

class User &lt; ActiveRecord::Base
  has_many :followers
  has_many :suspects, :through =&gt; :followers
end

class Connection &lt; ActiveRecord::Base
  belongs_to :user
  belongs_to :suspect, :primary_key =&gt; :case_id , :foreign_key =&gt; :case_id
end

class Suspect &lt; ActiveRecord::Base
  belongs_to :connection, :primary_key =&gt; :case_id , :foreign_key =&gt; :case_id
end

The problem is that the belongs_to seems to ignore the :primary key.

If I do

u = User.find(:first)
u.suspects

The SQL generated is:

SELECT `suspects`.* FROM `suspects` INNER JOIN `connections` ON `suspects`.id = `connections`.case_id WHERE ((`followers`.user_id = 1))

However it should be:

SELECT `suspects`.* FROM `suspects` INNER JOIN `connections` ON `suspects`.case_id = `connections`.case_id WHERE ((`followers`.user_id = 1))

This was partially fixed in 2.3.3 but not for has_many :through.

The patch applied to 2.3.3 can be found here: http://github.com/rails/rails/commit/b3ec7b2d03a52e43a4451d522eea7e6499289daa</original-body>
    <latest-body>Usingthe example code below:

class User &lt; ActiveRecord::Base
  has_many :followers
  has_many :suspects, :through =&gt; :followers
end

class Connection &lt; ActiveRecord::Base
  belongs_to :user
  belongs_to :suspect, :primary_key =&gt; :case_id , :foreign_key =&gt; :case_id
end

class Suspect &lt; ActiveRecord::Base
  belongs_to :connection, :primary_key =&gt; :case_id , :foreign_key =&gt; :case_id
end

The problem is that the belongs_to seems to ignore the :primary key.

If I do

u = User.find(:first)
u.suspects

The SQL generated is:

SELECT `suspects`.* FROM `suspects` INNER JOIN `connections` ON `suspects`.id = `connections`.case_id WHERE ((`followers`.user_id = 1))

However it should be:

SELECT `suspects`.* FROM `suspects` INNER JOIN `connections` ON `suspects`.case_id = `connections`.case_id WHERE ((`followers`.user_id = 1))

This was partially fixed in 2.3.3 but not for has_many :through.

The patch applied to 2.3.3 can be found here: http://github.com/rails/rails/commit/b3ec7b2d03a52e43a4451d522eea7e6499289daa</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;Usingthe example code below:&lt;/p&gt;
&lt;p&gt;class User &amp;lt; ActiveRecord::Base has_many :followers has_many
:suspects, :through =&amp;gt; :followers end&lt;/p&gt;
&lt;p&gt;class Connection &amp;lt; ActiveRecord::Base belongs_to :user
belongs_to :suspect, :primary_key =&amp;gt; :case_id , :foreign_key
=&amp;gt; :case_id end&lt;/p&gt;
&lt;p&gt;class Suspect &amp;lt; ActiveRecord::Base belongs_to :connection,
:primary_key =&amp;gt; :case_id , :foreign_key =&amp;gt; :case_id end&lt;/p&gt;
&lt;p&gt;The problem is that the belongs_to seems to ignore the :primary
key.&lt;/p&gt;
&lt;p&gt;If I do&lt;/p&gt;
&lt;p&gt;u = User.find(:first) u.suspects&lt;/p&gt;
&lt;p&gt;The SQL generated is:&lt;/p&gt;
&lt;p&gt;SELECT &lt;code&gt;suspects&lt;/code&gt;.* FROM &lt;code&gt;suspects&lt;/code&gt; INNER
JOIN &lt;code&gt;connections&lt;/code&gt; ON &lt;code&gt;suspects&lt;/code&gt;.id =
&lt;code&gt;connections&lt;/code&gt;.case_id WHERE
((&lt;code&gt;followers&lt;/code&gt;.user_id = 1))&lt;/p&gt;
&lt;p&gt;However it should be:&lt;/p&gt;
&lt;p&gt;SELECT &lt;code&gt;suspects&lt;/code&gt;.* FROM &lt;code&gt;suspects&lt;/code&gt; INNER
JOIN &lt;code&gt;connections&lt;/code&gt; ON &lt;code&gt;suspects&lt;/code&gt;.case_id =
&lt;code&gt;connections&lt;/code&gt;.case_id WHERE
((&lt;code&gt;followers&lt;/code&gt;.user_id = 1))&lt;/p&gt;
&lt;p&gt;This was partially fixed in 2.3.3 but not for has_many
:through.&lt;/p&gt;
&lt;p&gt;The patch applied to 2.3.3 can be found here: &lt;a href=&quot;http://github.com/rails/rails/commit/b3ec7b2d03a52e43a4451d522eea7e6499289daa&quot;&gt;
http://github.com/rails/rails/co...&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
  <ticket>
    <assigned-user-id type="integer" nil="true"></assigned-user-id>
    <attachments-count type="integer">2</attachments-count>
    <closed type="boolean">false</closed>
    <created-at type="datetime">2009-07-14T00:02:38+01:00</created-at>
    <creator-id type="integer">22106</creator-id>
    <milestone-due-on type="datetime">2010-01-15T00:00:00+00:00</milestone-due-on>
    <milestone-id type="integer">50064</milestone-id>
    <number type="integer">2907</number>
    <permalink>custom-counter_cache-is-not-used-when-using-collectionsize-method</permalink>
    <priority type="integer">6</priority>
    <project-id type="integer">8994</project-id>
    <raw-data type="binary" nil="true" encoding="base64"></raw-data>
    <state>open</state>
    <tag>2.3.6 active_record collection counter_cache patch</tag>
    <title>Custom counter_cache is not used when using collection.size method</title>
    <updated-at type="datetime">2010-01-25T10:40:54+00:00</updated-at>
    <user-id type="integer">59355</user-id>
    <user-name>pablo (at teambox)</user-name>
    <creator-name>Szymon Nowak</creator-name>
    <url>http://rails.lighthouseapp.com/projects/8994/tickets/2907</url>
    <milestone-title>2.3.6</milestone-title>
    <original-body>While writing a patch for belongs_to association, I've encountered the following issue:
@@@ ruby
class Author &lt; AR::Base
  has_many :posts
end
class Post &lt; AR::Base
  belongs_to :author, :counter_cache =&gt; &quot;custom_posts_count&quot;
end

a = Author.create
p = Post.create

p.author = a # updates counter on Author, but doesn't save post object

Author.find(a.id).send(:read_attribute, &quot;custom_posts_count&quot; # 1; uses counter cache
Author.find(a.id).posts.size # 0; uses SQL count
@@@

In the second example SQL count is used because in HasManyAssociation#count_records method, there's check if there's cache counter:
@@@ ruby
def has_cached_counter?
  @owner.attribute_present?(cached_counter_attribute_name)
end
def cached_counter_attribute_name
  &quot;#{@reflection.name}_count&quot;
end
@@@
which fails in this case. It simply uses name of the reflection, not the value of :counter_cache option on belongs_to association, or table name as described in [docs](http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#M002125).

Not sure if there's an easy solution for this if counter cache column name is defined on belongs_to association and not has_many.</original-body>
    <latest-body>While writing a patch for belongs_to association, I've encountered the following issue:
@@@ ruby
class Author &lt; AR::Base
  has_many :posts
end
class Post &lt; AR::Base
  belongs_to :author, :counter_cache =&gt; &quot;custom_posts_count&quot;
end

a = Author.create
p = Post.create

p.author = a # updates counter on Author, but doesn't save post object

Author.find(a.id).send(:read_attribute, &quot;custom_posts_count&quot; # 1; uses counter cache
Author.find(a.id).posts.size # 0; uses SQL count
@@@

In the second example SQL count is used because in HasManyAssociation#count_records method, there's check if there's cache counter:
@@@ ruby
def has_cached_counter?
  @owner.attribute_present?(cached_counter_attribute_name)
end
def cached_counter_attribute_name
  &quot;#{@reflection.name}_count&quot;
end
@@@
which fails in this case. It simply uses name of the reflection, not the value of :counter_cache option on belongs_to association, or table name as described in [docs](http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#M002125).

Not sure if there's an easy solution for this if counter cache column name is defined on belongs_to association and not has_many.</latest-body>
    <original-body-html>&lt;div&gt;&lt;p&gt;While writing a patch for belongs_to association, I've
encountered the following issue:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
class Author &amp;lt; AR::Base
  has_many :posts
end
class Post &amp;lt; AR::Base
  belongs_to :author, :counter_cache =&amp;gt; &amp;quot;custom_posts_count&amp;quot;
end

a = Author.create
p = Post.create

p.author = a # updates counter on Author, but doesn't save post object

Author.find(a.id).send(:read_attribute, &amp;quot;custom_posts_count&amp;quot; # 1; uses counter cache
Author.find(a.id).posts.size # 0; uses SQL count
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the second example SQL count is used because in
HasManyAssociation#count_records method, there's check if there's
cache counter:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
def has_cached_counter?
  @owner.attribute_present?(cached_counter_attribute_name)
end
def cached_counter_attribute_name
  &amp;quot;#{@reflection.name}_count&amp;quot;
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which fails in this case. It simply uses name of the reflection,
not the value of :counter_cache option on belongs_to association,
or table name as described in &lt;a href=&quot;/projects/8994/changesets/docs&quot; title=&quot;Changeset 'docs'&quot;&gt;[docs]&lt;/a&gt;(&lt;a href=&quot;http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#M002125&quot;&gt;http://api.rubyonrails.org/class...&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Not sure if there's an easy solution for this if counter cache
column name is defined on belongs_to association and not
has_many.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  </ticket>
</tickets>
