<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Rails all the way</title>
	<atom:link href="http://agilerails.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://agilerails.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sun, 31 May 2009 11:19:37 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='agilerails.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/2f7bf064c06b1ad19c9a0e581eefc3ca?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Rails all the way</title>
		<link>http://agilerails.wordpress.com</link>
	</image>
			<item>
		<title>IE throws &#8220;File Download Security Warning&#8221; on form submit</title>
		<link>http://agilerails.wordpress.com/2009/05/27/ie-throws-file-download-security-warning-on-form-submit/</link>
		<comments>http://agilerails.wordpress.com/2009/05/27/ie-throws-file-download-security-warning-on-form-submit/#comments</comments>
		<pubDate>Tue, 26 May 2009 22:20:09 +0000</pubDate>
		<dc:creator>agilerails</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[ie-6]]></category>
		<category><![CDATA[ie-7]]></category>
		<category><![CDATA[ie-bug]]></category>

		<guid isPermaLink="false">http://agilerails.wordpress.com/?p=75</guid>
		<description><![CDATA[I came across with this weird IE bug(occurs in IE-6 and IE-7 not in IE-8) that throws a File Download Security Warning on form post.
This is the code for the corresponding action inside controller

def update
&#160;respond_to do &#124;format&#124;
&#160;&#160;format.js   {....}
&#160;&#160;format.html {....}
&#160;end
end

* I guess this bug will only propagate if respond_to is used
I put a debugger [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilerails.wordpress.com&blog=547632&post=75&subd=agilerails&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I came across with this weird IE bug(occurs in IE-6 and IE-7 not in IE-8) that throws a File Download Security Warning on form post.</p>
<div id="attachment_77" class="wp-caption aligncenter" style="width: 520px"><img src="http://agilerails.files.wordpress.com/2009/05/2009-05-25_23191.png?w=510&#038;h=317" alt="File download security warning" title="IE issue" width="510" height="317" class="size-full wp-image-77" /><p class="wp-caption-text">File download security warning</p></div>
<p>This is the code for the corresponding action inside controller</p>
<pre>
def update
&nbsp;respond_to do |format|
&nbsp;&nbsp;format.js   {....}
&nbsp;&nbsp;format.html {....}
&nbsp;end
end
</pre>
<p>* I guess this bug will only propagate if respond_to is used</p>
<p>I put a debugger after the respond_to line and made a http post request through IE6 and IE7 browsers and hooked into the request parameters.</p>
<pre>
request.format =&gt; #&lt;Mime::Type:0x7b567a4 @string=&quot;image/jpeg&quot;, @synonyms=[], @symbol=nil &gt;
request.format.html? =&gt; nil
</pre>
<p>Making the same the request through Firefox returned this</p>
<pre>
request.format =&gt; #&lt;Mime::Type:0x55da8b8 @string="text/html", @synonyms=["application/xhtml+xml"], @symbol=:html &gt;
request.format.html? =&gt; true
request.format.js? =&gt; false
</pre>
<p>So one thing came into light that there is no Mime::Type registered for &#8220;images/jpeg&#8221; i.e format sent by IE</p>
<p>Looking at Rails 2.1.0 code actionpack/lib/action_controller/request.rb line no: 92</p>
<pre>
# Returns the Mime type for the format used in the request. If there is no format available, the first of the
# accept types will be used.
def format
  @format ||= parameters[:format] ? Mime::Type.lookup_by_extension(parameters[:format]) : accepts.first
end
</pre>
<p>And that brought me to the solution.If no request format is available, which is the case with IE, then the first format will be picked up.So moving format.html above the format.js will solve the problem(or i should say format.html should be the first format defined)</p>
<pre>
def update
&nbsp;respond_to do |format|
&nbsp;&nbsp;format.html {....}
&nbsp;&nbsp;format.js   {....}
&nbsp;end
end
</pre>
<p>Or we can also use format.any to our rescue(instead of moving format.html) </p>
<pre>
def update
&nbsp;respond_to do |format|
&nbsp;&nbsp;format.js   {....}
&nbsp;&nbsp;format.any  {....}
&nbsp;end
end
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilerails.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilerails.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilerails.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilerails.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilerails.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilerails.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilerails.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilerails.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilerails.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilerails.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilerails.wordpress.com&blog=547632&post=75&subd=agilerails&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://agilerails.wordpress.com/2009/05/27/ie-throws-file-download-security-warning-on-form-submit/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b22faacde254a50c258ce0f1dee3a29b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">agilerails</media:title>
		</media:content>

		<media:content url="http://agilerails.files.wordpress.com/2009/05/2009-05-25_23191.png" medium="image">
			<media:title type="html">IE issue</media:title>
		</media:content>
	</item>
		<item>
		<title>date_select, time_select doesn&#8217;t work with auto_prefix (object[])</title>
		<link>http://agilerails.wordpress.com/2009/03/11/date_select-time_select-doesnt-work-with-auto_prefix-object/</link>
		<comments>http://agilerails.wordpress.com/2009/03/11/date_select-time_select-doesnt-work-with-auto_prefix-object/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 07:30:47 +0000</pubDate>
		<dc:creator>agilerails</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[auto_prefix]]></category>
		<category><![CDATA[date_select]]></category>
		<category><![CDATA[time_select]]></category>
		<category><![CDATA[virtual_attribute]]></category>

		<guid isPermaLink="false">http://agilerails.wordpress.com/?p=14</guid>
		<description><![CDATA[I ran into the following issue while i was dealing with a multi-model form where a Sport is being saved with associated Events

&#60;%= render(:partial =&#62; "event", :collection =&#62; @sport.events) %&#62;

This partial is being rendered for collection of events for new/edit Sport

&#60;% new_or_existing = event.new_record? ? 'new' : 'existing' %&#62;
&#60;% prefix = "sport[#{new_or_existing}_event_attributes][]" %&#62;

&#60;% fields_for prefix, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilerails.wordpress.com&blog=547632&post=14&subd=agilerails&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I ran into the following issue while i was dealing with a multi-model form where a <em>Sport</em> is being saved with associated <em>Events</em></p>
<p><code><br />
&lt;%= render(:partial =&gt; "event", :collection =&gt; @sport.events) %&gt;<br />
</code><br />
<i>This partial is being rendered for collection of events for new/edit Sport</i><br />
<code><br />
&lt;% new_or_existing = event.new_record? ? 'new' : 'existing' %&gt;<br />
&lt;% prefix = "sport[#{new_or_existing}_event_attributes][]" %&gt;<br />
<br />
&lt;% fields_for prefix, event do |e| -%&gt;<br />
&nbsp;&lt;%= e.time_select("best_time") %&gt;<br />
&lt;% end -%&gt;<br />
</code></p>
<p><b>Here is the problem:</b></p>
<table>
<tr>
<td>For new <i>Event</i>, time_select name attribute should be:</td>
<td>&nbsp; <i>sport[new][][best_time(5i)]</i></td>
</tr>
<tr>
<td>but this was being assigned: </td>
<td>&nbsp; <i>sport[new][best_time(5i)]</i></td>
</tr>
</table>
<p>
Following error is thrown when this form is submitted<br />
<code><br />
Status: 500 Internal Server Error<br />
Conflicting types for parameter containers. Expected an instance of Hash but found an instance of Array<br />
</code></p>
<p>For more information regarding this issue you can go through this <a href="http://dev.rubyonrails.org/ticket/10551">ticket</a> </p>
<p>After digging into rails code this came into light<br />
<code><br />
# rails/actionpack/lib/action_view/helpers/form_helper.rb:508<br />
<br />
        if @object_name.sub!(/\[\]$/,"")<br />
&nbsp; if object ||= @template_object.instance_variable_get("@#{Regexp.last_match.pre_match}") and object.respond_to?(:to_param)<br />
&nbsp;&nbsp; @auto_index = object.to_param<br />
&nbsp; else<br />
&nbsp;&nbsp;  raise ArgumentError, "object[] naming but object param and @object var don't exist or don't respond to to_param: #{object.inspect}"<br />
&nbsp;          end<br />
        end<br />
</code></p>
<p>So here @object_name would be &#8220;sport[new_event_attributes][]&#8220;<br />
and @object_name.sub!(/\[\]$/,&#8221;") will return &#8220;sport[new_event_attributes]&#8220;<br />
and @auto_index will set to nil<br />
<br />
<em>select_time</em> internally calls <em>option_with_prefix</em> to assign name attribute for select element<br />
<code><br />
#rails/actionpack/lib/action_view/helpers/date_helper.rb:664<br />
<br />
def options_with_prefix(position, options)<br />
&nbsp;prefix = "#{@object_name}"<br />
&nbsp;if options[:index]<br />
&nbsp;&nbsp;prefix &lt;&lt; "[#{options[:index]}]"<br />
&nbsp;elsif @auto_index<br />
&nbsp;&nbsp;prefix &lt; "#{prefix}[#{@method_name}(#{position}i)]")<br />
&nbsp;end<br />
end<br />
</code></p>
<p>Work around: pass a non nil index value along with date_select or time_select<br />
<code><br />
&lt;% new_or_existing = event.new_record? ? 'new' : 'existing' %&gt;<br />
&lt;% prefix = "sport[#{new_or_existing}_event_attributes][]" %&gt;<br />
<br />
&lt;% fields_for prefix, event do |e| -%&gt;<br />
&nbsp;&lt;%= e.time_select("best_time", :index =&gt; event.id || "") %&gt;<br />
&lt;% end -%&gt;<br />
</code></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilerails.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilerails.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilerails.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilerails.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilerails.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilerails.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilerails.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilerails.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilerails.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilerails.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilerails.wordpress.com&blog=547632&post=14&subd=agilerails&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://agilerails.wordpress.com/2009/03/11/date_select-time_select-doesnt-work-with-auto_prefix-object/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b22faacde254a50c258ce0f1dee3a29b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">agilerails</media:title>
		</media:content>
	</item>
		<item>
		<title>time_zone_select showing only US time zones</title>
		<link>http://agilerails.wordpress.com/2008/01/04/time_zone_select-showing-only-us-time-zones/</link>
		<comments>http://agilerails.wordpress.com/2008/01/04/time_zone_select-showing-only-us-time-zones/#comments</comments>
		<pubDate>Fri, 04 Jan 2008 11:20:12 +0000</pubDate>
		<dc:creator>agilerails</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[time_zone_select rails US time_zones]]></category>

		<guid isPermaLink="false">http://agilerails.wordpress.com/2008/01/04/time_zone_select-showing-only-us-time-zones/</guid>
		<description><![CDATA[time_zone_select produces option tags for almost any time zones in the world but if you want the list of US time zones only,  without using the TZInfo library then you should add a file under the lib directory say us.rb and add the following code

class US
&#160;def self.all
&#160;&#160;TimeZone.us_zones
&#160;end
end

and in you views use

&#60;%= time_zone_select object, method, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilerails.wordpress.com&blog=547632&post=13&subd=agilerails&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>time_zone_select produces option tags for almost any time zones in the world but if you want the list of US time zones only,  <u>without using the TZInfo library</u> then you should add a file under the <i>lib directory </i>say <i><u>us.rb</u> </i>and add the following code<br />
<code><br />
class US<br />
&nbsp;def self.all<br />
&nbsp;&nbsp;TimeZone.us_zones<br />
&nbsp;end<br />
end<br />
</code><br />
and in you views use<br />
<code><br />
&lt;%= time_zone_select object, method, nil, :model=&gt;US  %&gt;<br />
</code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/agilerails.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/agilerails.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilerails.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilerails.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilerails.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilerails.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilerails.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilerails.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilerails.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilerails.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilerails.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilerails.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilerails.wordpress.com&blog=547632&post=13&subd=agilerails&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://agilerails.wordpress.com/2008/01/04/time_zone_select-showing-only-us-time-zones/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b22faacde254a50c258ce0f1dee3a29b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">agilerails</media:title>
		</media:content>
	</item>
		<item>
		<title>Etag in Rails</title>
		<link>http://agilerails.wordpress.com/2007/09/03/etag-in-edge-rails/</link>
		<comments>http://agilerails.wordpress.com/2007/09/03/etag-in-edge-rails/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 19:50:51 +0000</pubDate>
		<dc:creator>agilerails</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[etag]]></category>
		<category><![CDATA[etags]]></category>

		<guid isPermaLink="false">http://agilerails.wordpress.com/2007/09/03/etag-in-edge-rails/</guid>
		<description><![CDATA[What is an ETag and How does it work??
When a request is made for the first time then during page render, etag header is automatically inserted on 200 OK responses. The etag is calculated using MD5 of the response body.
On subsequent requests the etag is send along as  request.headers['HTTP_IF_NONE_MATCH']  and compared with response.headers['ETAG'] [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilerails.wordpress.com&blog=547632&post=12&subd=agilerails&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><b>What is an ETag and How does it work??</b></p>
<p>When a request is made for the first time then during page render, etag header is automatically inserted on 200 OK responses. The etag is calculated using MD5 of the response body.<br />
On subsequent requests the etag is send along as  <i>request.headers['HTTP_IF_NONE_MATCH']</i>  and compared with <i>response.headers['ETAG']</i> . If they are equal then the response is changed to a <i>304 Not Modified</i> and the response body is set to an empty string.</p></blockquote>
<p><b>So how does that help??</b></p>
<ul>
<li>ETag is used to expire the browser caching and for saving transfer of course!!</li>
<li> aggregators can tell which version of feed they have and thus server sends data only if some newer version is there.</li>
<li> no more cache based on page expiration.</li>
</ul>
<p><b>A ruby snippet for showing ETags</b></p>
<p><code><br />
require 'net/http'<br />
# my rails app running on edge rails<br />
http = Net::HTTP.new("localhost", 3000)<br />
<br />
# /controller/action<br />
data = http.get2("/say")<br />
p data.body<br />
p data.header.each{|k,v| p "#{k} = #{v}"}<br />
<br />
data2 = http.request_get("/say", {'If-None-Match'  =&gt;  data.header['etag']})<br />
p data2.body<br />
p data2.header.each{|k,v| p "#{k} = #{v}"}<br />
# <i>304 not modified</i> n <i>body</i> empty coz of no change in content<br />
</code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/agilerails.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/agilerails.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilerails.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilerails.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilerails.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilerails.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilerails.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilerails.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilerails.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilerails.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilerails.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilerails.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilerails.wordpress.com&blog=547632&post=12&subd=agilerails&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://agilerails.wordpress.com/2007/09/03/etag-in-edge-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b22faacde254a50c258ce0f1dee3a29b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">agilerails</media:title>
		</media:content>
	</item>
	</channel>
</rss>