<?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/"
	>

<channel>
	<title>Code Iteratively &#187; howto</title>
	<atom:link href="http://iterat.ive.ly/index.php/tag/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://iterat.ive.ly</link>
	<description>code. cycling. music.</description>
	<lastBuildDate>Wed, 08 Sep 2010 19:50:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Upgrading your Authlogic Gem for&#160;Rails3</title>
		<link>http://iterat.ive.ly/index.php/2010/09/03/upgrading-your-authlogic-gem-for-rails3/</link>
		<comments>http://iterat.ive.ly/index.php/2010/09/03/upgrading-your-authlogic-gem-for-rails3/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 08:45:17 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rails3]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=431</guid>
		<description><![CDATA[If you&#8217;re using Authlogic in Rails3 (or if you&#8217;re upgrading your existing app from 2.3.8 to Rails3) you really need to be using the rails3 branch of the Authlogic gem. If you&#8217;re using Bundler, this is super-easy because you just need to update your Gemfile. In your Gemfile, update the authlogic line to be: gem [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using Authlogic in Rails3 (or if you&#8217;re upgrading your existing app from 2.3.8 to Rails3) you really need to be using the <a href="http://github.com/odorcicd/authlogic/tree/rails3">rails3 branch</a> of the Authlogic gem.  If you&#8217;re using <a href="http://gembundler.com/">Bundler</a>, this is super-easy because you just need to update your Gemfile.</p>
<p>In your Gemfile, update the authlogic line to be:</p>
<pre class="brush:ruby;gutter:false">
gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'
</pre>
<p>Now you should run <code>$ bundle install</code> to grab the new gem. Then, there are just a few more deprecated things in Rails3 that you&#8217;ll need to change in your upgraded app. I&#8217;ll try to enumerate here from memory, so please forgive me if I forget something.</p>
<p><span id="more-431"></span>First, you need to update your ApplicationController because #requesturi is outdated.  Replace it with #fullpath:</p>
<pre class="brush:ruby;gutter:false;">
def store_location
  session[:return_to] = request.fullpath
end
</pre>
<p>Second, you need to drop the filter_parameter_logging setting from your ApplicationController because it&#8217;s now handled in the new application.rb file.  Just remember to add the :password_confirmation field to the default array like so:</p>
<pre class="brush:ruby;gutter:false;">
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password, :password_confirmation]
</pre>
<p>Third, if your migration script (or the steps you followed manually) didn&#8217;t get rid of the /config/initializers/cookie_verification_secret.rb file, delete it now.  Cookie secrets are now handled in the /config/initializers/secret_token.rb file.</p>
<p>Fourth, the f.error_message construct isn&#8217;t available anymore in core rails, so you should take this opportunity to create your own better more customizable error messages.  If you really really want to keep using f.error_message you can install the dynamic_form plugin, but don&#8217;t do that.  Railscast.com did a very nice explanation of <a href="http://asciicasts.com/episodes/211-validations-in-rails-3">how to create your own shared _error_messages.html.erb view</a> (along with some other validation-related stuff.)</p>
<p>Finally, you need to make sure your generated pages include the csrf_meta_tag. <a href="http://iterat.ive.ly/index.php/2010/09/03/invalidauthenticitytoken-on-logout-attempt-using-authlogic/">Check out my previous post</a> if you&#8217;re getting an InvalidAuthenticityToken error when you hit the Logout link.</p>
<p>That should be all you need to do to have Authlogic working in Rails3 without deprecated warnings.</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/09/03/upgrading-your-authlogic-gem-for-rails3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InvalidAuthenticityToken on Logout when using&#160;Authlogic</title>
		<link>http://iterat.ive.ly/index.php/2010/09/03/invalidauthenticitytoken-on-logout-attempt-using-authlogic/</link>
		<comments>http://iterat.ive.ly/index.php/2010/09/03/invalidauthenticitytoken-on-logout-attempt-using-authlogic/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 08:07:46 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rails3]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=416</guid>
		<description><![CDATA[This one took me a while to debug. When upgrading my existing application to Rails 3 almost everything was working fine except whenever I would click the Logout link I would get an error because Rails couldn&#8217;t verify that the UserSessionsController#destroy request was valid from my app. This is the error message shown: ActionController::InvalidAuthenticityToken in [...]]]></description>
			<content:encoded><![CDATA[<p>This one took me a while to debug. When upgrading my existing application to Rails 3 almost everything was working fine except whenever I would click the Logout link I would get an error because Rails couldn&#8217;t verify that the UserSessionsController#destroy request was valid from my app.</p>
<p>This is the error message shown:<br />
<code>ActionController::InvalidAuthenticityToken in User sessionsController#destroy</code></p>
<p><code>actionpack (3.0.0) lib/action_controller/metal/ request_forgery_protection.rb:96:in `verify_authenticity_token'</code></p>
<p>And the solution is simple, you just need to add the new csrf_meta_tag helper to your generated page (probably in the /views/layouts/application.html.erb file).</p>
<p><span id="more-416"></span></p>
<pre class="brush:html;highlight:7">
...
&lt;head&gt;
  &lt;meta http-equiv="content-type" content="text/html;charset=UTF-8" /&gt;
  &lt;title&gt;Some Title&lt;/title&gt;
  &lt;%= stylesheet_link_tag :all %&gt;
  &lt;%= javascript_include_tag :defaults %&gt;
  &lt;%= csrf_meta_tag %&gt;
&lt;/head&gt;
...
</pre>
<p>Line 7 is the one you care about and need to have in your html.erb file.</p>
<p>This helper includes the appropriate meta tags which make the authenticity_token available to the handleMethod javascript function.  In Rails3, links generated with the link_to helper which use a :method other than GET get passed through that handleMethod function in rails.js.  That function creates a temporary form, sets some parameters and submits it.  And if you&#8217;re using protect_from_forgery (you should be) all non-GET requests are checked to prevent Cross Site Request Forgery (CSRF).  So, if those meta tags don&#8217;t exist on your page, the handleMethod function doesn&#8217;t know what your authenticity_token is, and the request will be rejected with the error above.</p>
<p>Line 5 below is an example of my main nav logout link that was causing the problem when clicked.  No change was required to this code after doing the above fix.</p>
<pre class="brush:ruby;highlight:5">
&lt;% if !current_user %&gt;
  &lt;%= link_to "Log In", new_user_session_path %&gt; |
  &lt;%= link_to "Register", new_account_path %&gt; |
&lt;% else %&gt;
  &lt;%= link_to "Logout", user_session_path, :method =&gt; :delete %&gt; |
&lt;% end %&gt;
</pre>
<p>This isn&#8217;t specific to Authlogic&#8217;s logout click &#8211; any time you are using link_to now in Rails3 with non-GET methods, it uses unobtrusive javascript. And if you&#8217;re missing the csrf_meta_tag helper, any unobtrusive javascript posts will fail to validate. </p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2010/09/03/invalidauthenticitytoken-on-logout-attempt-using-authlogic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOWTO: Export IIS7 Configuration to Another&#160;Webserver</title>
		<link>http://iterat.ive.ly/index.php/2009/06/10/howto-export-iis7-configuration-to-another-webserver/</link>
		<comments>http://iterat.ive.ly/index.php/2009/06/10/howto-export-iis7-configuration-to-another-webserver/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 21:15:15 +0000</pubDate>
		<dc:creator>Christopher Gooley</dc:creator>
				<category><![CDATA[dot.net]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[iis7]]></category>
		<category><![CDATA[infrastructure]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://iterat.ive.ly/?p=140</guid>
		<description><![CDATA[IIS7 has this great new feature called Shared Configuration.  Except that it has a tendency to do horrible things which usually result in all the websites and application pools being removed from your server and your production website starting to serve 503 Service Unavailable errors. For an innexplicable reason, Microsoft decided to kill the Export [...]]]></description>
			<content:encoded><![CDATA[<p>IIS7 has this great new feature called Shared Configuration.  Except that it has a tendency to do horrible things which usually result in all the websites and application pools being removed from your server and your production website starting to serve 503 Service Unavailable errors.</p>
<p>For an innexplicable reason, Microsoft decided to kill the Export function from IIS7 in favor of this new feature.  But for those of us who don&#8217;t trust technology, we like to do things manually and to get a repeatable result that doesn&#8217;t update automatically when we least expect it.  Yes, I am the sort of person who wonders why the default Windows Update on servers is to Install and Reboot Automatically at 2am&#8230;</p>
<p>In any case, in a simple 3 step process you too can export and import your Internet Information Server 7 websites and app pools.<span id="more-140"></span></p>
<p>I will call the target server TWEB (this is the server where you want a duplicate configuration) and the source server SWEB (this is where the current configuration exists).</p>
<p>First, on TWEB make a backup copy of the files in C:\Windows\System32\inetsrv\config.  I just created a subfolder called &#8220;bak&#8221; and copied them.  <strong>This is very important.  If you forget or skip this step because backups are for sissies, you will be re-installing IIS7 in step 4.</strong></p>
<p>Second, copy the AppliationHost.config from SWEB into the C:\Windows\System32\inetsrv\config folder on TWEB.  Also copy any application files like your c:\websites folder or whatever over to TWEB in the appropriate location if you haven&#8217;t already.</p>
<p><img class="alignright" src="http://f.ive.ly/Aen.jpg" alt="" width="198" height="110" />Third, on TWEB open both the new ApplicationHost.config and the backup ApplicationHost.config from step 1 and locate the &lt;configProtectedData&gt; node in the backup.  Copy that node and replace it into the new config file.</p>
<p>Fourth, if you didn&#8217;t backup the existing config file, remove the IIS role and add it back, then start at step 1.</p>
<p><strong>Note:</strong> if you have custom accounts under which you&#8217;re running app pools (cuz you&#8217;re not using LocalSystem, right?) then you just need to go into the IIS Management Console and re-configure the passwords for those accounts.  They were encrypted with the other server&#8217;s AES keys so they won&#8217;t be valid on this server and the pools won&#8217;t start.</p>
<p>That&#8217;s it.  Hope that helps.  It should work the same for C# .NET applications (which is what I&#8217;m using) or just static websites or whatever.  But of course, you shouldn&#8217;t trust me.  Test it yourself first.</p>
<p>My new good-karma policy is that if I spend more than an hour tracking down a general bug or wacky configuration thing, I promise to blog the solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://iterat.ive.ly/index.php/2009/06/10/howto-export-iis7-configuration-to-another-webserver/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
