<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Danger: ActiveRecord, param hashes, and symbol keys</title>
	<atom:link href="http://blog.lrdesign.com/2010/03/danger-activerecord-param-hashes-and-symbol-keys/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lrdesign.com/2010/03/danger-activerecord-param-hashes-and-symbol-keys/</link>
	<description>Logical Reality Design: Web Design and Software Development</description>
	<lastBuildDate>Tue, 20 Dec 2011 19:03:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Evan</title>
		<link>http://blog.lrdesign.com/2010/03/danger-activerecord-param-hashes-and-symbol-keys/comment-page-1/#comment-19165</link>
		<dc:creator>Evan</dc:creator>
		<pubDate>Mon, 07 Feb 2011 17:24:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=109#comment-19165</guid>
		<description>@Dave:

If you are merging two hashes, like I was, and you want to make sure AR respects the items you are specifying, then specify all your hashes with string keys.  i.e., say this:

prepopulated_fields = { &#039;address&#039; =&gt; &#039;100 main st.&#039;, &#039;city&#039; =&gt; &#039;Pasadena&#039; }
build_payment(prepopulated_fields.merge!(params[:payment]))

That way, if params[:payment]  has a nil &#039;address&#039;, it will get overridden by your &#039;address&#039; because they have the same key.    The problem only occurs when one of the sources has a key &#039;address&#039; (string) and the other has a key :address (symbol), which allows both to exist in the hash simultaneously.</description>
		<content:encoded><![CDATA[<p>@Dave:</p>
<p>If you are merging two hashes, like I was, and you want to make sure AR respects the items you are specifying, then specify all your hashes with string keys.  i.e., say this:</p>
<p>prepopulated_fields = { &#8216;address&#8217; => &#8217;100 main st.&#8217;, &#8216;city&#8217; => &#8216;Pasadena&#8217; }<br />
build_payment(prepopulated_fields.merge!(params[:payment]))</p>
<p>That way, if params[:payment]  has a nil &#8216;address&#8217;, it will get overridden by your &#8216;address&#8217; because they have the same key.    The problem only occurs when one of the sources has a key &#8216;address&#8217; (string) and the other has a key :address (symbol), which allows both to exist in the hash simultaneously.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Casciotti</title>
		<link>http://blog.lrdesign.com/2010/03/danger-activerecord-param-hashes-and-symbol-keys/comment-page-1/#comment-19163</link>
		<dc:creator>Dave Casciotti</dc:creator>
		<pubDate>Mon, 07 Feb 2011 16:03:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.lrdesign.com/?p=109#comment-19163</guid>
		<description>I am new to RoR and wasn&#039;t sure what the resolution was.</description>
		<content:encoded><![CDATA[<p>I am new to RoR and wasn&#8217;t sure what the resolution was.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

