<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>The Dev Blog comments</title>
    <link>http://devblog.famundo.com</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Putting Family Management on Rails!</description>
    <item>
      <title>"IE is braindead! (Wild card certs and https redirects)" by Craig Francis</title>
      <description>&lt;p&gt;I second the FireFox vote... actually, I would say any alternative browser, as Opera, Safari, iCab etc all work really well.&lt;/p&gt;

&lt;p&gt;And as a side note, for those using PHP, I normally have this little 'goto' function available on my websites...&lt;/p&gt;



&lt;p&gt;function goto($goto) {&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if (isset($_SERVER['HTTPS']) &amp;amp;&amp;amp; $_SERVER['HTTPS'] == 'on') {
    if (preg_match('/http:\/\//', $goto)) {
        header('Refresh: 0; URL=' . $goto);
        exit('&amp;lt;a href="' . htmlentities($goto) . '"&amp;gt;Loading...&amp;lt;/a&amp;gt;');
    }
}

header('Location: ' . $goto);
exit('&amp;lt;p&amp;gt;Goto &amp;lt;a href="' . htmlentities($goto) . '"&amp;gt;next page&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;');
&lt;/code&gt;&lt;/pre&gt;

}

&lt;p&gt;Sorry if the indenting does not work, but I bet you can guess what the main body of this function is for (yes, the retarded browser).&lt;/p&gt;</description>
      <pubDate>Tue, 03 Apr 2007 05:43:29 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:37a9eaeb-2a1a-4e31-a4be-de400c49a455</guid>
      <link>http://devblog.famundo.com/articles/2007/04/02/ie-is-braindead-wild-card-certs-and-https-redirects#comment-115</link>
    </item>
    <item>
      <title>"IE is braindead! (Wild card certs and https redirects)" by Guy Naor</title>
      <description>&lt;p&gt;I'm happy we are getting more and more Firefox users! The share of Firefox has benn constantly growing for us. And not only here in the blog which is developers oriented. Even the main Famundo website and the application itself. &lt;/p&gt;</description>
      <pubDate>Mon, 02 Apr 2007 16:48:40 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:d9f66c40-5929-4049-a748-e4edfafb8a18</guid>
      <link>http://devblog.famundo.com/articles/2007/04/02/ie-is-braindead-wild-card-certs-and-https-redirects#comment-114</link>
    </item>
    <item>
      <title>"IE is braindead! (Wild card certs and https redirects)" by pcx99</title>
      <description>&lt;p&gt;Good thing your pages don't use javascript's prompt command or you'd have another thing to add to your list ;)&lt;/p&gt;</description>
      <pubDate>Mon, 02 Apr 2007 16:44:05 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:a08bafad-f3d9-4bb3-a0ed-5a11e483ec0e</guid>
      <link>http://devblog.famundo.com/articles/2007/04/02/ie-is-braindead-wild-card-certs-and-https-redirects#comment-113</link>
    </item>
    <item>
      <title>"Lost In Binding - Adventures In Ruby Metaprogramming" by Guy Naor</title>
      <description>&lt;p&gt;Piers, unfortunately the code you posted still doesn't work. The reason it doesn't is that we still have an internal block in the call to form_tag that goes into the concatenator.&lt;/p&gt;

&lt;p&gt;But I did find a way of using capture which simplifies the code (though still makes it look a bit hackish...):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def secure_form_tag(*form_tag_params, &amp;amp;block)
  if block_given?
    @res = &amp;lt;&amp;lt;-EOF
      #{form_tag(*form_tag_params)}
      #{capture(&amp;amp;block)}
      #{hidden_field_tag('session_id_validation', security_token)}
      &amp;lt;/form&amp;gt;
    EOF
    eval '_erbout.concat @res', block
  else
    &amp;quot;#{form_tag(*form_tag_params)} #{hidden_field_tag('session_id_validation', security_token)}&amp;quot;
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;BTW, notice the need to use @res to make it work, or the var is hidden from the block bindings.&lt;/p&gt;

&lt;p&gt;Thanks again for the capture trick, didn't see it before :-)&lt;/p&gt;</description>
      <pubDate>Sun, 01 Apr 2007 14:32:20 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:5949764b-3bb1-4d38-87cd-c6c9fb043250</guid>
      <link>http://devblog.famundo.com/articles/2007/03/28/lost-in-binding-adventures-in-ruby-metaprogramming#comment-112</link>
    </item>
    <item>
      <title>"Lost In Binding - Adventures In Ruby Metaprogramming" by Guy Naor</title>
      <description>&lt;p&gt;Piers,&lt;/p&gt;

&lt;p&gt;This is nice, though like you said, not much different with regard to all the copying of the strings, which I suspect can't be prevented.&lt;/p&gt;

&lt;p&gt;Thanks for the idea!&lt;/p&gt;</description>
      <pubDate>Sun, 01 Apr 2007 10:19:13 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:9ab8eb9d-6f07-4e03-80e8-06ecc0fabba5</guid>
      <link>http://devblog.famundo.com/articles/2007/03/28/lost-in-binding-adventures-in-ruby-metaprogramming#comment-111</link>
    </item>
    <item>
      <title>"Lost In Binding - Adventures In Ruby Metaprogramming" by Piers Cawley</title>
      <description>&lt;p&gt;Dang, forgot to replace both calls to &lt;code&gt;hidden_field_tag&lt;/code&gt; in that rewritten &lt;code&gt;secure_form_tag&lt;/code&gt;. &lt;em&gt;L'esprit d'escalier&lt;/em&gt; strikes again.&lt;/p&gt;</description>
      <pubDate>Sat, 31 Mar 2007 16:41:09 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:3a278c55-305f-48d9-9597-1e0ba165fd25</guid>
      <link>http://devblog.famundo.com/articles/2007/03/28/lost-in-binding-adventures-in-ruby-metaprogramming#comment-110</link>
    </item>
    <item>
      <title>"Lost In Binding - Adventures In Ruby Metaprogramming" by Piers Cawley</title>
      <description>&lt;p&gt;Ah yes, of course.&lt;/p&gt;

&lt;p&gt;Further inspection of the docs suggests that:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def security_token_field
  hidden_field_tag &amp;quot;session_id_validation&amp;quot;), security_token
end

def concatenator(binding)
  lambda {|str| concat(str, binding)}
end

def secure_form_tag(*form_tag_params, &amp;amp;block)
  if block_given?
    form_body = capture &amp;amp;block;
    concatenator(block).call \
      form_tag(*form_tag_params) { security_token_field + form_body }
  else
    &amp;quot;#{form_tag(*form_tag_params)}
#{hidden_field_tag('session_id_validation', security_token)}&amp;quot;
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Should do the trick. All that ugliness with &lt;code&gt;string_eval&lt;/code&gt; still happens, but it's hidden behind the abstraction wall.&lt;/p&gt;

&lt;p&gt;I may have got a little bit Higher Order Function happy on &lt;code&gt;concatenate&lt;/code&gt;'s ass.&lt;/p&gt;</description>
      <pubDate>Sat, 31 Mar 2007 16:39:05 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:77c6ae85-ee76-4c8e-b08c-a363b9c61263</guid>
      <link>http://devblog.famundo.com/articles/2007/03/28/lost-in-binding-adventures-in-ruby-metaprogramming#comment-109</link>
    </item>
    <item>
      <title>"Lost In Binding - Adventures In Ruby Metaprogramming" by Guy Naor</title>
      <description>&lt;p&gt;Piers,&lt;/p&gt;

&lt;p&gt;Unfortunately this can't work. I wish it was that simple :-).&lt;/p&gt;

&lt;p&gt;The reason it doesn't, is that when using &lt;pre&gt;form_tag(...) do end&lt;/pre&gt; the form and /form tags wrap the form elements around the block. And so our added hidden field will be outside the form. We need a way to inject the hidden field into the block.&lt;/p&gt;</description>
      <pubDate>Fri, 30 Mar 2007 09:02:42 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:8db3d321-c9f9-45c9-ab6f-9a8d51ef38b2</guid>
      <link>http://devblog.famundo.com/articles/2007/03/28/lost-in-binding-adventures-in-ruby-metaprogramming#comment-108</link>
    </item>
    <item>
      <title>"Lost In Binding - Adventures In Ruby Metaprogramming" by Piers Cawley</title>
      <description>&lt;p&gt;I've not tried it, but what's wrong with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;form_tag(url_for_options, *parameters_for_url, &amp;amp;block)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you don't create a new block, you don't have to create a new binding.&lt;/p&gt;</description>
      <pubDate>Fri, 30 Mar 2007 03:15:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:94e78043-76b7-45c3-9bf4-cbf5ec6a6003</guid>
      <link>http://devblog.famundo.com/articles/2007/03/28/lost-in-binding-adventures-in-ruby-metaprogramming#comment-107</link>
    </item>
    <item>
      <title>"Lost In Binding - Adventures In Ruby Metaprogramming" by K. Adam Christensen</title>
      <description>&lt;p&gt;What if you just did a concat on the hidden tag and the block's binding and then pass that block into the form_for method.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://pastie.caboo.se/50396" rel="nofollow"&gt;http://pastie.caboo.se/50396&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not tested, but an idea.&lt;/p&gt;</description>
      <pubDate>Thu, 29 Mar 2007 16:58:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:8db4acd5-96ae-4d85-816f-9957dbfffec3</guid>
      <link>http://devblog.famundo.com/articles/2007/03/28/lost-in-binding-adventures-in-ruby-metaprogramming#comment-106</link>
    </item>
  </channel>
</rss>
