<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Recent Posts in 'protect_from_forgery problems with example app in chapter 1' | Pragmatic Forums</title>
    <link>http://forums.pragprog.com/forums/50/topics/168</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <description></description>
    <item>
      <title>protect_from_forgery problems with example app in chapter 1 posted by Mike Naberezny @ Sun, 10 Feb 2008 03:16:50 -0000</title>
      <description>&lt;p&gt;Brandon,&lt;/p&gt;


	&lt;p&gt;Yes, the example was updated in the second beta release of our &amp;#8220;Rails for &lt;span class="caps"&gt;PHP&lt;/span&gt; Developers&amp;#8221; book.&lt;/p&gt;


	&lt;p&gt;On this website, visit &amp;#8220;Your Account&amp;#8221; and then select &amp;#8220;Regenerate a &lt;span class="caps"&gt;PDF&lt;/span&gt;&amp;#8221; from the sidebar.  From there, you can select to generate the latest &lt;span class="caps"&gt;PDF&lt;/span&gt; for &amp;#8220;Rails for &lt;span class="caps"&gt;PHP&lt;/span&gt; Developers&amp;#8221; that includes this change and quite a few others.&lt;/p&gt;


	&lt;p&gt;Regards,&lt;br /&gt;Mike&lt;/p&gt;</description>
      <pubDate>Sun, 10 Feb 2008 03:16:50 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:50:168:2276</guid>
      <author>Mike Naberezny</author>
      <link>http://forums.pragprog.com/forums/50/topics/168</link>
    </item>
    <item>
      <title>protect_from_forgery problems with example app in chapter 1 posted by brandon shi @ Sun, 10 Feb 2008 02:03:48 -0000</title>
      <description>&lt;p&gt;Derek, are you talking about the Beta version of the Rails book? I can&amp;#8217;t seem to find it in my account for download.&lt;/p&gt;</description>
      <pubDate>Sun, 10 Feb 2008 02:03:48 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:50:168:2275</guid>
      <author>brandon shi</author>
      <link>http://forums.pragprog.com/forums/50/topics/168</link>
    </item>
    <item>
      <title>protect_from_forgery problems with example app in chapter 1 posted by Donal Ellis @ Wed, 12 Dec 2007 12:50:17 -0000</title>
      <description>&lt;p&gt;Thanks Derek, got the updated pdf and tried out the new version of the example, nice! Up to chapter 3 and enjoying the book a lot!&lt;/p&gt;</description>
      <pubDate>Wed, 12 Dec 2007 12:50:17 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:50:168:2018</guid>
      <author>Donal Ellis</author>
      <link>http://forums.pragprog.com/forums/50/topics/168</link>
    </item>
    <item>
      <title>protect_from_forgery problems with example app in chapter 1 posted by Derek DeVries @ Wed, 12 Dec 2007 07:15:01 -0000</title>
      <description>&lt;p&gt;Donal,&lt;/p&gt;


	&lt;p&gt;Thanks for pointing this out.&lt;/p&gt;


	&lt;p&gt;As you found out, the error occurs because of the &lt;span class="caps"&gt;CSRF&lt;/span&gt; (Cross-Site Request Forgery) protection added to Rails 2.0. We missed updating this example to account for the &lt;span class="caps"&gt;CSRF&lt;/span&gt; feature when we released the initial beta.&lt;/p&gt;


	&lt;p&gt;You were on the right track with the hidden &amp;#8220;authenticity_token&amp;#8221; field, but the preferred way is to use a form helper as you mention. The current beta version of the book (released just a couple days ago), updates the example to do just this. We&amp;#8217;ve made this fix along with others, so now is a good time to get the newest version of the beta book in your pragprog account.&lt;/p&gt;


	&lt;p&gt;Derek&lt;/p&gt;</description>
      <pubDate>Wed, 12 Dec 2007 07:15:01 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:50:168:2017</guid>
      <author>Derek DeVries</author>
      <link>http://forums.pragprog.com/forums/50/topics/168</link>
    </item>
    <item>
      <title>protect_from_forgery problems with example app in chapter 1 posted by Donal Ellis @ Wed, 12 Dec 2007 03:17:41 -0000</title>
      <description>&lt;p&gt;Hi&lt;/p&gt;


	&lt;p&gt;Being a rails/ruby newbie, I spent a lot of time (but learned a lot) getting your simple app in chapter 1 to work. I worked out that because protect_from_forgery is turned on by default in application.rb, whenever i posted the form in the example, I got an ActionController::InvalidAuthenticityToken exception thrown. I could see I could comment out the call to protect_from_forgery and so avoid the problem, but I couldn&amp;#8217;t work out why it wasn&amp;#8217;t working&amp;#8230;&lt;/p&gt;


	&lt;p&gt;So finally I worked out I had to manually put the token (obtained with a call to form_authenticity_token) in a hidden field named &amp;#8220;authenticity_token&amp;#8221; in the form. This is done for you if you&amp;#8217;re using a helper to create the form, but this is not the case in the example.&lt;/p&gt;


	&lt;p&gt;You might want to work this in to your example somehow to avoid the problem&amp;#8230;or I might be just missing something, so please let me know if I am.&lt;/p&gt;


	&lt;p&gt;Otherwise, really enjoying the book, thanks.&lt;/p&gt;


	&lt;p&gt;Donal&lt;/p&gt;</description>
      <pubDate>Wed, 12 Dec 2007 03:17:41 -0000</pubDate>
      <guid isPermaLink="false">forums.pragprog.com:50:168:2016</guid>
      <author>Donal Ellis</author>
      <link>http://forums.pragprog.com/forums/50/topics/168</link>
    </item>
  </channel>
</rss>
