<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2909074750209490543</id><updated>2011-11-01T18:56:35.682+13:00</updated><category term='rails mssql sql server date'/><category term='ruby'/><category term='firefox'/><category term='ADOExplorer'/><category term='fastcgi'/><category term='iis'/><category term='tool'/><category term='rails'/><category term='rails iis mongrel isapi'/><category term='ror'/><category term='disable'/><category term='autocomplete'/><category term='backspace'/><category term='sql server'/><category term='ie'/><category term='ado'/><category term='db'/><category term='group_by'/><title type='text'>Murrays ROR Rails Notes</title><subtitle type='html'>How to's and explanations on things related to Ruby On Rails ROR. plus patches to extend where some basics are missing.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-3936608759384448961</id><published>2008-01-22T13:39:00.000+13:00</published><updated>2008-01-22T13:40:27.152+13:00</updated><title type='text'>read_multipart fault with "bad boundary end of body part"</title><content type='html'>&lt;h4&gt;Intro&lt;/h4&gt;
&lt;p&gt;This one has been bugging be for ages, My application would fault at random times with, "bad boundary end of body part"
from the read_multipart in ActionController. I finally took a very close look.  &lt;/p&gt;
&lt;p&gt;I have a form, with a quite few fields, uses can also add attachments so the post is via multipart.&lt;/p&gt;
&lt;p&gt;I worked out the odds of this happening (once I found a solution) are approx 1 in 120, and was suprised this has not cropped up before. 
There cant be many rails apps, with large data entry screens using multipart out there&lt;/p&gt;

&lt;h4&gt;What happens in read_multipart&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;If your post content is greater than 10240 bytes, read_multipart fills up buff with 10240 bytes&lt;/li&gt;
&lt;li&gt;The code to extract params, will see the "--boundary[CR][LF]" and extract the param and delete up to the bounday, and then loop for the next param&lt;/li&gt;
&lt;li&gt;But if the buff ends with "--boundary[CR][LF]", on extracing the param the buff is zero length&lt;/li&gt;
&lt;li&gt;But for some reason, If buff is zero  a break is issued and then a fault happens&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;What wrong&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;A check for zero bytes read, is performed previously in the code, why do it again??&lt;/li&gt;
&lt;li&gt;I cant figure out why you would check the buff for zero length??, when it is valid to be zero.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;The fix&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Dont break if buff is zero length !!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Edit /ruby/lib/ruby/gems/1.8/gems/actionpack-2.x.x/lib/action_controller/request.rb&lt;/p&gt;
&lt;pre&gt;

def read_multipart(body, boundary, content_length, env)

  etc ...

 buf = buf.sub(/\A((?:.|\n)*?)(?:[\r\n]{1,2})?#{quoted_boundary}([\r\n]{1,2}|--)/n) do
    content.print $1
    if "--" == $2
      content_length = -1
    end
    boundary_end = $2.dup
    ""
  end
  
  etc ...

  # break if buf.size == 0 # Dont break on zero, as buf could end on a boundary !!! resulting in empty buff
  break if content_length == -1
  
  etc...

&lt;/pre&gt;

&lt;h4&gt;Rails Ticket&lt;/h4&gt;
Checkout &lt;a href="http://dev.rubyonrails.org/ticket/10886"&gt;rails ticket 10886&lt;/a&gt; just lodged for updates.

&lt;h4&gt;Finally&lt;/h4&gt;
&lt;p&gt;If some one knows why the buff zero length is/was needed, I would like to know&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-3936608759384448961?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/3936608759384448961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=3936608759384448961' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/3936608759384448961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/3936608759384448961'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2008/01/readmultipart-fault-with-bad-boundary.html' title='read_multipart fault with &quot;bad boundary end of body part&quot;'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-2794171695551111110</id><published>2007-12-20T09:32:00.000+13:00</published><updated>2007-12-20T09:33:05.664+13:00</updated><title type='text'>Rails v2.0 with IIS MSSQL ISAPI_Rewrite3</title><content type='html'>&lt;h4&gt;Intro&lt;/h4&gt;
&lt;p&gt;This is an update to my blog on running rails with IIS and Mondrel using MSSQL, This update details the steps for a rails v2.0 application (rather than 1.8)&lt;/p&gt;
&lt;p&gt;My Rails app is not heavely used (2 full time, several casual users), so a proxy/redirect from IIS to single Mongrel seemed ideal.&lt;p&gt;
&lt;p&gt;IIS will still service up the static/public content, and all other requests are forwarded to Mongrel(s). Using ISAPI_Rewrite3 from &lt;a href="http://www.helicontech.com/"&gt;Helicon Tech&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;ISAPI_Rewrite3 is cool it mimics Apache mod_rewrite.&lt;/p&gt; 
&lt;p&gt;Also I needed to re-document the install/set-up so here it is. &lt;/p&gt; 

&lt;h3&gt;Install Software&lt;/h3&gt;
&lt;h4&gt;Overview&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Ruby is installed in C:\ruby &lt;/li&gt;
&lt;li&gt;Rails applications are under C:\rails &lt;/li&gt;
&lt;li&gt;Rails application is called "rapp" (Rails application). And in C:\rails\rapp&lt;/li&gt;
&lt;li&gt;SQL Express is the database.&lt;/li&gt;
&lt;li&gt;A install CD with all relevant software/gems is available on R:\downloads&lt;/li&gt; 
&lt;/ul&gt;

&lt;h4&gt;Install MSSQL&lt;/h4&gt;
&lt;p&gt;Install MSSQL with a named instance SQL$RAPP this will allow you to shutdown one rails application DB, without affecting others.&lt;/p&gt; 
&lt;pre&gt;
&gt; cd R:\downloads
&gt; dotnetfx.exe  # Install .Net Frame work 2.0 
&gt; SQLEXPR32-SP2.EXE # MS SQl Server 2005 Express with SP2,
&lt;b&gt;Untick "Hide Advanced Options" to allow a named instance to be insalled&lt;/b&gt;  
# Used Named Instance "RAPP" based on name of rails application
# Used mixed authentication, "sa" passsword "*********"
&gt; SQLServer2005_SSMSEE-SP2.msi # MS Sql Server Managment Studio  with SP2
&lt;/pre&gt;
&lt;h4&gt;Configure MSSQL&lt;/h4&gt;
&lt;p&gt;Rails connects to MSSQL using tcp/ip. This is not enabled by default 
&lt;pre&gt;
&gt; SQLServerManager.msc # Start "SQL Server Configeration Manager"

SQL Server Network Configuration -&gt; Protocols for RAPP -&gt; Enable TCP/IP
SQL Native Client Configuration -&gt; Client Protocols -&gt; Enable TCP/IP 

&lt;/pre&gt;

&lt;h4&gt;Install Ruby&lt;/h4&gt;
&lt;p&gt;This is included for completeness&lt;/p&gt;
&lt;pre&gt;
&gt; cd R:\downloads
&gt; ruby186-25.exe # Install ruby # source: &lt;a href="http://rubyforge.org/frs/?group_id=167"&gt;ruby&lt;/a&gt; 
# Select Install "Ruby" and "Enable RubyGems"
# Install to "C:\ruby 
# Check C:\ruby\bin to your everyones path !!
# If not added, My Computer -&gt; Properties -&gt; 
        Advanced -&gt;  Environment  Variables -&gt; System Variables

&gt; cd R:\downloads\rubygems-0.9.4  # source: &lt;a href="http://rubyforge.org/frs/?group_id=126"&gt;rubygems&lt;/a&gt;   
# NOTE: &lt;b&gt;Use 0.9.4 as mongrel does not install correctly with 0.9.5&lt;/b&gt; 
&gt; ruby setup.rb # Install ruby gems
&lt;/pre&gt;

&lt;h4&gt;Install Rails/Mogrel&lt;/h4&gt;
&lt;pre&gt;
&gt; cd C:\downloads
&gt; gem install rake # &lt;a href="http://rubyforge.org/projects/rake/"&gt;http://rubyforge.org/projects/rake/&lt;/a&gt;
Successfully installed rake-0.7.3

&gt; gem install rails # &lt;a href="http://rubyforge.org/projects/rails/"&gt;"http://rubyforge.org/projects/rails/&lt;/a&gt;
Successfully installed activesupport-2.0.1
Successfully installed activerecord-2.0.1
Successfully installed actionpack-2.0.1
Successfully installed actionmailer-2.0.1
Successfully installed activeresource-2.0.1
Successfully installed rails-2.0.1

&gt; gem install mongrel # pick the win32, # &lt;a href="http://mongrel.rubyforge.org/"&gt;http://mongrel.rubyforge.org/&lt;/a&gt;
Successfully installed gem_plugin-0.2.3
Successfully installed cgi_multipart_eof_fix-2.5.0
Successfully installed mongrel-1.1.1-mswin32

&gt; gem install mongrel_service --source http://gems.rubyforge.org  # pick the win32
Successfully installed win32-service-0.5.2-mswin32
Successfully installed mongrel_service-0.3.3-mswin32

&lt;/pre&gt;

&lt;h4&gt;Install MSSQL Drivers&lt;/h4&gt;
&lt;p&gt;Install MSSQL Drivers (DBI/ADO drivers)&lt;/p&gt; 
&lt;pre&gt;
&gt; cd R:\downloads\ruby-dbi-0.1.1 # &lt;a href="http://rubyforge.org/projects/ruby-dbi/"&gt;http://rubyforge.org/projects/ruby-dbi/&lt;/a&gt;
&gt; ruby setup.rb config --with=dbd_ado
&gt; ruby setup.rb setup
&gt; ruby setup.rb install
&lt;/pre&gt;
&lt;p&gt;Install sqlserver adapter (as now packaged seperately) - this is available from http://gems.rubyonrails.org &lt;/p&gt;
&lt;pre&gt;
&gt; gem install activerecord-sqlserver-adapter --source http://gems.rubyonrails.org
&lt;/pre&gt;

&lt;h4&gt;Install RMagick / Faster CSV&lt;/h4&gt;
&lt;p&gt;NOTE: When including rmagic in your rails app. Use the full name rmagic.rb, 
as depending on your paths rgagic.so may be included rather than rmagic.rb&lt;/p&gt;
&lt;pre&gt;
&gt; cd R:\downloads\rmagick-1.15.9 # &lt;a href="http://rubyforge.org/projects/rmagick/"&gt;http://rubyforge.org/projects/rmagick/&lt;/a&gt; win32
&gt; ImageMagick-6.3.5-8-Q8-windows-dll.exe
# Install to C:\ruby\ImageMagick
# Tick [x] Update executable search path.
&gt; gem install rmagick-1.15.9-x86-mswin32-60.gem --local
# Note: Documentation is in 
# C:\ruby\lib\ruby\gems\1.8\gems\rmagick-x.x.x-win32\doc\index.html
&lt;/pre&gt;
&lt;pre&gt;
&gt; cd R:\downloads
&gt; gem install fastercsv-1.2.0 --local
&lt;/pre&gt;


&lt;h4&gt;Install Iaspi Rewriter&lt;/h4&gt;
&lt;pre&gt;
&gt; cd R:\downloads
&gt; ISAPI_Rewrite3_00xx.msi # &lt;a href="http://www.helicontech.com/isapi_rewrite/"&gt;http://www.helicontech.com/isapi_rewrite/&lt;/a&gt;
# Install to C:\Inetpub\ISAPI_Rewrite3\
&gt; Run C:\Inetpub\ISAPI_Rewrite3\Helicon Manager.exe
# And Register product # See: serialno.txt for the serial number
&lt;/pre&gt;


&lt;h3&gt;Patch and Patch&lt;/h3&gt;

&lt;h4&gt;Patch Active Record - SQL Server Adapter&lt;/h4&gt;
&lt;p&gt;SQL 2005 differs from previous versions, it reports null columns as uppercase NULL and you need to patch the sqlserver_adapter.rb&lt;/p&gt; 
&lt;pre&gt;
# Patch  sqlserver_adapter.rb (See Rails Ticket #7733) for server 2005
&gt; cd C:\ruby\lib\ruby\gems\1.8\gems\activerecord-sqlserver-adapter-1.0.0\
              lib\active_record\connection_adapters
&gt; edit sqlserver_adapter.rb
# Line ~304: default = ...... "=~ /null/ ? nil"   ==&gt; 
      "=~ /null/i ? nil"  # Case insensitive match on the word
&lt;/pre&gt;

&lt;h4&gt;Patch Action Controller - CGI Process&lt;/h4&gt;
&lt;p&gt;When preforming a re-direct the header is inspected for the real host when request 
has been forward, however rails does not strip any extra white space.&lt;/p&gt;
&lt;pre&gt;
&gt; cd C:\ruby\lib\ruby\gems\1.8\gems\actionpack-2.0.1\lib\action_controller
&gt; edit cgi_process.rb

    def host_with_port_without_standard_port_handling
      if forwarded = env["HTTP_X_FORWARDED_HOST"]
        forwarded.split(/,\s?/).last
      etc ...

# Line ~87: forwarded.split(/,\s?/).last  ==&gt; 
#    forwarded.split(/,\s?/).last.strip # strip extra spaces/tabs 
&lt;/pre&gt;
&lt;h4&gt;Patch SQL Server Adapter - to handel dates prior to 1970&lt;/h4&gt;
&lt;p&gt;This is detailed in a seperate post, Check out 
&lt;a href="http://mspeight.blogspot.com/2007/12/solved-rails-mssql-dates-prior-to-1970.html"&gt;SOLVED: Rails + MSSQL dates prior to 1970&lt;/a&gt; &lt;/p&gt;



&lt;h3&gt;Create/Configure Rails Application&lt;/h3&gt;

&lt;h4&gt;Create Rails Application&lt;/h4&gt;
&lt;pre&gt;
&gt; mkdir C:\rails
&gt; cd C:\rails
&gt; rails rapp # Create rails app called rapp
&lt;/pre&gt;
&lt;h4&gt;Add in some addins&lt;/h4&gt;
&lt;p&gt;Active record "acts_as_list" is now a plugin add it in, I also recommend annotate_models from "Agile Developemnt With Rails"&lt;/p&gt; 
&lt;pre&gt;
&gt; cd C:\rails\rapp
&gt; gem install acts_as_list  --source http://gems.rubyforge.org
&gt; ruby script/plugin install file://C:\downloads\annotate_models 
&gt; ruby script/plugin install http:#svn.pragprog.com/Public/plugins/annotate_models
&lt;/pre&gt;


&lt;h4&gt;Create Rails "Hello World" Application&lt;/h4&gt;
&lt;pre&gt;
&gt; ruby script/generate controller hello
&lt;/pre&gt;
&lt;p&gt;Edit C:\rails\rapp\app\controllers\hello_controller.rb. And past in this code. &lt;/p&gt;
&lt;pre&gt;
class HelloController &lt; ApplicationController
   $render_count ||= 0
   def world
     $render_count += 1
     render :text =&amp;gt;  "&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt;
               Page rendered #{$render_count} times.&amp;lt;/body&amp;lt;/html&amp;gt;"
   end
end
&lt;/pre&gt;
&lt;p&gt;Woops: We dont have a database yet, so remove the requirement&lt;/p&gt;
&lt;pre&gt;
  Edit \rails\rapp\config\environment.rb
  # No database support, remove active_record etc ..
  config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
&lt;/pre&gt;
&lt;p&gt;Test basic application works with WebBrick&lt;/p&gt;
&lt;pre&gt;
&gt; cd C:\rails\rapp
&gt; ruby script/server # Run WebBrick to test 
&gt; iexplore.exe http://localhost:3000/hello/world 
# Should get hello world page
&gt; Ctrl+break # Close WebBrick
&lt;/pre&gt;

&lt;h4&gt;Host using mongrel service&lt;/h4&gt;
&lt;p&gt;Perform the following steps to host rapp using mongrel&lt;/p&gt;
&lt;p&gt;NOTE: We will be hosting this rails application under the relative url "/rapp"&lt;/p&gt;
&lt;p&gt;NOTE: We only bind to localhost (127.0.0.1), since IIS will eventually forward locally to mongrel&lt;/p&gt;
&lt;p&gt;The port chosen is 4004&lt;/p&gt;

&lt;pre&gt;
&gt; cd C:\rails\rapp
&gt; mongrel_rails service::install -N rails_rapp -a 127.0.0.1 
         -c C:\rails\rapp -p 4004 -e production --prefix /rapp
# NOTE: adding --prefix /rapp, sets 
#      ActionController::AbstractRequest.relative_url_root = "/rapp"
&gt; sc config rails_rapp start= auto
&gt; net start rails_rapp
# To remove the service use: mongrel_rails service::remove -N rails_rapp
&lt;/pre&gt;

&lt;h4&gt;Permissions&lt;/h4&gt;
&lt;p&gt;Mongrel service will be running as SYSTEM or NETWORK SERVICE, You need to check/give the following permissions.&lt;p&gt;
&lt;ul&gt;
&lt;li&gt;Give FULL permission for C:\rails\rapp\temp and C:\rails\rapp\log&lt;/li&gt;
&lt;li&gt;Give FULL permission to TEMP (C:\WINDOWS\TEMP)&lt;/li&gt;
&lt;li&gt;Give FULL permission to any other folders your rails app1 writes to (e.g C:\rails\app1\public\attachments )&lt;/li&gt;
&lt;li&gt;Check Read/Execute permissions for C:\ruby\* and C:\ruby\ImageMagick&lt;/li&gt;
&lt;li&gt;Check Read permission Under HKEY_CLASSES_ROOT\ADODB.Connection for both the ADODB.Connection and ADODB.Connection.X.X entries # mssql only&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
 
&lt;h4&gt;Test using mongrel service&lt;/h4&gt;
&lt;p&gt;Browse to http://localhost:4004/rapp/hello/world, Note all url's are now relative to rapp, This allows multiple rails apps to be hosted behind iis&lt;/p&gt;
&lt;pre&gt;
&gt; iexplore.exe http://localhost:4004/rapp/hello/world 
# Should get hello world page, Rendered for the 1st time 
# Press refresh a few times, See the counter grow.
&lt;/pre&gt;

&lt;h4&gt;Now to host behind IIS&lt;/h4&gt;
&lt;p&gt;Create a virtial directory, so IIS services up the public/static portion of the site, (i.e. C:\rails\rapp\public)&lt;/p&gt;
&lt;pre&gt;
&gt; mkdir C:\Inetpub\Logfiles
&gt; inetmgr.exe # Change log file folder
  # Goto -&gt; Default Web Site -&gt; Properties -&gt; Web Site Tab -&gt; Logging properties
    Log file directory -&gt; C:\Inetpub\Logfiles

&gt; inetmgr.exe # Add in your application
  # Goto -&gt; Default Web Site -&gt; New -&gt; Virtual Directory -&gt; 
    Alias/Name -&gt; rapp
    Directory/Path -&gt; C:\rails\rapp\public
    Permissions -&gt; Read + Scripts + Executables
    
    # Note: Need Execute otherwise proxy/forwarding does not work !!!! 
&lt;/pre&gt;
&lt;h4&gt;Test static portion&lt;/h4&gt;
&lt;p&gt;Browse to http://localhost/rapp/index.html - You should see the standard welcome to rails page&lt;/p&gt;
&lt;pre&gt;
&gt; iexplore.exe http://localhost/rapp/index.html 
# Should get the "Rails Welcome aboard" 
&lt;/pre&gt;

&lt;h4&gt;Configure ISAPI_Rewrite3 to forward to Mongrel&lt;/h4&gt;
&lt;p&gt;Confiure ISAPI_Rewrite to forward all http://host/rapp/* to mongrel on http://127.0.0.1:4004/rapp/*. 
NOTE: We do not forward requests contining a full stop (.), So files like .js and .css etc will be serviced up by iis&lt;/p&gt;
&lt;pre&gt;
&gt; C:\Inetpub\ISAPI_Rewrite3\Helicon Manager.exe
    Click -&gt; Edit
    Enter your new rule
        RewriteProxy rapp/([^.]+)$ http://127.0.0.1:4004/rapp/$1
&lt;/pre&gt; 
&lt;p&gt;Your "C:\Inetpub\ISAPI_Rewrite3\httpd.conf" file should look something like&lt;/p&gt;
&lt;pre&gt;
# Helicon ISAPI_Rewrite configuration file
# Version 3.0.0.23
RewriteEngine on
RewriteBase /
RewriteProxy rapp/([^.]+)$ http://127.0.0.1:4004/rapp/$1
&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Rails .htaccess legacy&lt;/b&gt;&lt;br&gt;Remove/Rename the c:\rails\rapp\public\.htaccess file, 
as this is read by ISAPI_Rewrite but is designed for Apache !!! &lt;/p&gt;
&lt;pre&gt;
&gt; rename c:\rails\rapp\public\.htaccess c:\rails\rapp\public\apache.htaccess
&lt;/pre&gt;

&lt;h4&gt;Test mongrel/dynamic portion&lt;/h4&gt;
&lt;p&gt;Browse to http://localhost/rapp/hello/world  - You should see the Hello World with counter from last test&lt;/p&gt;
&lt;pre&gt;
&gt; iisreset # restart iis
&gt; iexplore.exe http://localhost/rapp/hello/world
# Should get hello world page, Rendered for the nth time 
&lt;/pre&gt;

&lt;h3&gt;Finished&lt;/h3&gt;
&lt;p&gt;You should now have a working rails application, behind IIS using Mongrel. &lt;br&gt;
To add another application simply nominate a new relative url and repeat the above steps&lt;p&gt;

&lt;h4&gt;Multiple Applications&lt;/h4&gt;
When running multiple rails applications, Set the session key to be unique for each 
instance, otherwise you will be trying to share session keys across multiple apps.
&lt;pre&gt;
&gt; Edit \rails\rapp\controllers\application.rb
  config.action_controller.session = {
    :session_key =&gt; '_&lt;b&gt;rapp&lt;/b&gt;_session',
    :secret      =&gt; '571 etc... a0263'
  }
&lt;/pre&gt;

&lt;h4&gt;Notes on: SSL/HTTPS and ISAPI_Rewrite3 with RewriteProxy&lt;/h4&gt;
&lt;p&gt;If you are running  IIS with SSL, You need to pass to the backend application than fact you are running https://&lt;/p&gt;
&lt;p&gt;The header needs to contain "X-Forwarded-Proto: https", ISAPI_Rewrite3 does not add this for you as it does for X-Forward-Host etc. 
So we need to do it ourselves if using https&lt;/p&gt;

&lt;p&gt;Edit your "C:\Inetpub\ISAPI_Rewrite3\httpd.conf" to contain the following, Before any RewriteProxy &lt;/p&gt;
&lt;pre&gt;
# Add "X-Forwarded-Proto: https" to the header so back end knows if running with ssl/https
RewriteCond %{HTTPS} ^on$
RewriteHeader X-Forwarded-Proto: .* https

RewriteProxy etc ....
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-2794171695551111110?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/2794171695551111110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=2794171695551111110' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/2794171695551111110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/2794171695551111110'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/12/rails-v20-with-iis-mssql-isapirewrite3.html' title='Rails v2.0 with IIS MSSQL ISAPI_Rewrite3'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-6889589791428026694</id><published>2007-12-17T10:24:00.000+13:00</published><updated>2007-12-17T10:27:12.905+13:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rails mssql sql server date'/><title type='text'>SOLVED: Rails + MSSQL dates prior to 1970</title><content type='html'>&lt;h4&gt;Intro&lt;/h4&gt;
&lt;p&gt;MSSQL Microsft SQL Server only stores dates as datetime, As a consequence this is interperted by rails as a Time class, 
however a Time class cannot have dates prior to 1970, So effectively a date_select etc will raise an exception, for dates prior to 1970. 
If the column is in reality just a date, why not make it a date.&lt;/p&gt;
&lt;p&gt;A have tested hoping rails v2.0 solves this but to no avail, So I needed to go back to my original solution.&lt;p&gt;
&lt;p&gt;My solution relies on manually changing the base type of such fields back to date. Hope this helps others.&lt;/p&gt;
&lt;h4&gt;What to patch/change&lt;/h4&gt;
&lt;p&gt;(1) We need to allow a model to change the type of a column. So we patch SQLServerColumn to allow the type to be changed&lt;/p&gt;
&lt;p&gt;(2) Edit each model to change, the appropriate columns datatype after_initialize.&lt;/p&gt;
&lt;p&gt;(3) Patch "SQLServerColumn" to return a date for a date.&lt;/p&gt;

&lt;h4&gt;Allow column type to be change&lt;/h4&gt;
&lt;p&gt;Create lib/sql_server_column_ext.rb&lt;/p&gt;
&lt;pre&gt;
# Patch SqlServerColumn as may need to change column type from datetime to a date, as time cannot be -ve (&lt; 1970) !!!
class ActiveRecord::ConnectionAdapters::SQLServerColumn
  def type=(val)
    @type=val
  end
end 
&lt;/pre&gt;
&lt;p&gt;Edit config/environment.rb&lt;/p&gt;
&lt;pre&gt;
require 'sql_server_column_ext.rb'
&lt;/pre&gt;

&lt;h4&gt;Change data type on column, after initalized &lt;/h4&gt;
&lt;p&gt;Edit model (e.g app/models/patient.rb) &lt;/p&gt;
&lt;pre&gt;
  @@patched_date_of_birth_type=false
  def after_initialize
    if ( !@@patched_date_of_birth_type )
       date_of_birth_column = Patient.columns_hash['date_of_birth']
       date_of_birth_column.type= :date
       @@patched_date_of_birth_type=true
    end
  end
&lt;/pre&gt;

&lt;h4&gt;Fix up SQLServerColumn&lt;/h4&gt;
&lt;p&gt;Edit C:\ruby\lib\ruby\gems\1.8\gems\activerecord-sqlserver-adapter-1.0.0\lib\active_record\connection_adapters\sqlserver_adapter.rb&lt;/p&gt;
&lt;p&gt;Implement code to return a date not DateTime when a column has a type of :date&lt;/p&gt;
&lt;p&gt;Change "type_cast" method and introduce new method "cast_to_date". The code almost works without this change, 
but weird things (dates becomming null) because of issues related to converting between Date and Time and vise versa. &lt;/p&gt; 
&lt;pre&gt;
def type_cast(value)
   etc...
   when :date      then cast_to_date(value)  # was cast_to_datetime(value)
   etc...
end

def cast_to_date(value)
  return value.to_date if value.is_a?(Date) || value.is_a?(Time) || value.is_a?(DBI::Timestamp) # DateTime is_a? Date
  if value.is_a?(String) 
    date_array = ParseDate.parsedate(value)
    return Date.new(*date_array[0..2]) rescue nil
  end
  return nil
end

&lt;/pre&gt;


&lt;h4&gt;Finally&lt;/h4&gt;
&lt;p&gt;If there is a more elegant solution I would very much like to know&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-6889589791428026694?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/6889589791428026694/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=6889589791428026694' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/6889589791428026694'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/6889589791428026694'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/12/solved-rails-mssql-dates-prior-to-1970.html' title='SOLVED: Rails + MSSQL dates prior to 1970'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-3174334067334509974</id><published>2007-10-09T14:53:00.000+13:00</published><updated>2007-12-20T09:46:44.225+13:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rails iis mongrel isapi'/><title type='text'>HOW TO: Rails under IIS with Mongrel and ISAPI_Rewrite3</title><content type='html'>&lt;h4&gt;Update - Dec - 2007 &lt;/h4&gt;
&lt;p&gt;&lt;b&gt;I have updated this entry for rails 2.0 &lt;br&gt;
Check out &lt;a href="http://mspeight.blogspot.com/2007/12/rails-v20-with-iis-mssql-isapirewrite3.html"&gt;Rails v2.0 with IIS, ISAPI_Rewrite3, Mongrel&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;

&lt;h4&gt;Intro&lt;/h4&gt;
&lt;p&gt;I have been running multiple rails apps under IIS using fast cgi, I was gettting very frustrated (No hair left), It seems to fault one a week. (Think this is related to the size of a post)&lt;/p&gt;
&lt;p&gt;The Rails apps are not heavily used each with (~3 full time, several casual users), so a proxy/redirect from IIS to single Mongrel seemed ideal.&lt;p&gt;
&lt;p&gt;IIS will still service up the static/public content, and all other requests are forwarded to Mongrel(s). Using ISAPI_Rewrite3 from &lt;a href="http://www.helicontech.com/"&gt;Helicon Tech&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;ISAPI_Rewrite3 is cool it mimics Apache mod_rewrite.&lt;/p&gt; 
&lt;p&gt;Also I needed to document the install/set-up so here it is. &lt;/p&gt; 

&lt;h3&gt;Install Software&lt;/h3&gt;
&lt;h4&gt;Overview&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Ruby is installed in C:\ruby &lt;/li&gt;
&lt;li&gt;Rails applications are under C:\rails &lt;/li&gt;
&lt;li&gt;Rails application is called "rapp" (Rails application). And in C:\rails\rapp&lt;/li&gt;
&lt;li&gt;SQL Express is the database.&lt;/li&gt;
&lt;li&gt;A install CD with all relevant software/gems is available on R:\&lt;/li&gt; 
&lt;/ul&gt;

&lt;h4&gt;Install SQL/Express&lt;/h4&gt;
&lt;p&gt;Install IIS with a named instance SQL$RAPP this will allow you to shutdown one rails application DB, without affecting others.&lt;/p&gt; 
&lt;pre&gt;
C:&gt; cd R:\mssql
C:&gt; dotnetfx.exe  # Install .Net Frame work 2.0 
C:&gt; SQLEXPR32-SP2.EXE # MS SQl Server 2005 Express with SP2, 
# Used Named Instance "RAPP" based on name of rails application
# Used mixed authentication, "sa" password "you-choose"
C:&gt; SQLServer2005_SSMSEE-SP2.msi # MS Sql Server Managment Studio  with SP2
&lt;/pre&gt;

&lt;h4&gt;Install Ruby&lt;/h4&gt;
&lt;p&gt;This is included for completeness&lt;/p&gt;
&lt;pre&gt;
C:&gt; cd R:\ruby
C:&gt; ruby186-25.exe # Install ruby 
# Select Install "Ruby" and "Enable RubyGems"
# Install to "C:\ruby 
# Check C:\ruby\bin to your everyones path !!
# If not added, My Computer -&gt; Properties -&gt; Advanced -&gt;  Environment  Variables -&gt; System Variables
C:&gt; cd R:\ruby\rubygems-0.9.4
C:&gt; ruby setup.rb # Install ruby gems
&lt;/pre&gt;

&lt;h4&gt;Install Rails/Mogrel&lt;/h4&gt;
&lt;pre&gt;
C:&gt; cd R:\ruby
C:&gt; gem install activesupport-1.4.2 --local
C:&gt; gem install activerecord-1.15.3 --local
C:&gt; gem install actionpack-1.13.3 --localexit

C:&gt; gem install actionmailer-1.3.3 --local
C:&gt; gem install actionwebservice-1.2.3 --local
C:&gt; gem install rails-1.2.3 --local
C:&gt; gem install win32-service-0.5.2-mswin32 --local
C:&gt; gem install gem_plugin-0.2.2 --local
C:&gt; gem install cgi_multipart_eof_fix-2.3 --local
C:&gt; gem install mongrel-1.0.1-mswin32 --local
C:&gt; gem install mongrel_service  --local
&lt;/pre&gt;

&lt;h4&gt;Install MSSQL Drivers&lt;/h4&gt;
&lt;pre&gt;
C:&gt; cd R:\ruby\ruby-dbi-0.1.1
C:&gt; ruby setup.rb config --with=dbd_ado
C:&gt; ruby setup.rb setup
C:&gt; ruby setup.rb install
&lt;/pre&gt;

&lt;h4&gt;Patch Active Record - SQL Server Adapter&lt;/h4&gt;
&lt;p&gt;SQL 2005 differs from previous versions, it reports null columns as uppercase NULL and you need to patch the sqlserver_adapter.rb&lt;/p&gt; 
&lt;pre&gt;
# Patch  sqlserver_adapter.rb (See Rails Ticket #7733) for server 2005
C:&gt; cd C:\ruby\lib\ruby\gems\1.8\gems\activerecord-1.15.3\lib\active_record\connection_adapters
C:&gt; edit sqlserver_adapter.rb
# Line ~282: "=~ /null/ ? nil"   ==&gt; "=~ /null/&lt;b&gt;i&lt;/b&gt; ? nil"  # Case insensitive match on the word 
&lt;/pre&gt;


&lt;h4&gt;Install RMagick / Faster CSV&lt;/h4&gt;
&lt;p&gt;NOTE: When require RMagick in your rails app. Use the full name require 'RMagick.rb', 
as depending on your paths RMagick.so may be included rather than RMagick.rb&lt;/p&gt;
&lt;pre&gt;
C:&gt; cd R:\ruby\RMagick-1.14.1_IM-6.3.0-7-Q8
C:&gt; ImageMagick-6.3.0-7-Q8-windows-dll.exe 
# Install to C:\ruby\ImageMagick-6.3.0-Q8
# Tick [x] Update executable search path.
C:&gt; gem install rmagick-1.14.1-win32 --local
# Note: Documentation is in C:\ruby\lib\ruby\gems\1.8\gems\rmagick-1.14.1-win32\doc\index.html
&lt;/pre&gt;

&lt;h4&gt;Install Faster CSV&lt;/h4&gt;
&lt;pre&gt;
C:&gt; cd R:\ruby
C:&gt; gem install fastercsv-1.2.0 --local
&lt;/pre&gt;

&lt;h4&gt;Install Iaspi Rewriter&lt;/h4&gt;
&lt;small&gt;&lt;b&gt;UPDATE 30-Oct-2006: You need to install build 29 or above, Prior versions doubled up on cookie data from other sessions.
This effectively gave a new session, the session from the last person accessing the site !!! (A bit scary!!) &lt;/b&gt;&lt;/small&gt;
&lt;pre&gt;
C:&gt; cd R:\ISAPI_Rewrite3
C:&gt; ISAPI_Rewrite3_00xx.msi
# Install to C:\Inetpub\ISAPI_Rewrite3\

&lt;/pre&gt;

&lt;h4&gt;Patch Action Controller - CGI Process&lt;/h4&gt;
&lt;p&gt;When preforming a re-direct the header is inspected for the real host when request 
has been forward, however rails does not strip any extra white space.&lt;/p&gt;
&lt;pre&gt;
# Patch cgi_process.rb
C:&gt; cd C:\ruby\lib\ruby\gems\1.8\gems\actionpack-1.13.3\lib\action_controller
C:&gt; edit cgi_process.rb
# Line ~83: forwarded.split(/,\s?/).last  ==&gt; forwarded.split(/,\s?/).last.&lt;b&gt;strip&lt;/b&gt; # strip extra spaces/tabs 
&lt;/pre&gt;

&lt;h3&gt;Create/Configure Rails Application&lt;/h3&gt;

&lt;h4&gt;Create Rails "Hello World" Application&lt;/h4&gt;
&lt;pre&gt;
C:&gt; mkdir C:\rails
C:&gt; cd C:\rails
C:&gt; rails rapp # Create rails app called rapp
C:&gt; cd rapp
C:&gt; ruby script/generate controller hello
&lt;/pre&gt;
&lt;p&gt;Edit C:\rails\rapp\app\controllers\hello_controller.rb. And past in this code. &lt;/p&gt;
&lt;pre&gt;
class HelloController &lt; ApplicationController
   $render_count ||= 0
   def world
     $render_count += 1
     render :text =&amp;gt; "&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt;Page rendered #{$render_count} times.&amp;lt;/body&amp;lt;/html&amp;gt;"
   end
end
&lt;/pre&gt;
&lt;p&gt;Test basic application works with WebBrick&lt;/p&gt;
&lt;pre&gt;
C:&gt; cd C:\rails\rapp
C:&gt; ruby script/server # Run WebBrick to test 
C:&gt; iexplore.exe http://localhost:3000/hello/world 
# Should get hello world page
C:&gt; Ctrl+break # Close WebBrick
&lt;/pre&gt;

&lt;h4&gt;Host using mongrel service&lt;/h4&gt;
&lt;p&gt;Perform the following steps to host rapp using mongrel&lt;/p&gt;
&lt;p&gt;NOTE: We will be hosting this rails application under the relative url "/rapp"&lt;/p&gt;
&lt;p&gt;NOTE: We only bind to localhost (127.0.0.1), since IIS will eventually forward locally to mongrel. The port chosen is 4004&lt;/p&gt;

&lt;pre&gt;
C:&gt; cd C:\rails\rapp
C:&gt; mongrel_rails service::install -N rails_rapp -a 127.0.0.1 -c C:\rails\rapp -p 4004 -e production --prefix /rapp
# NOTE: adding --prefix /rapp, sets ActionController::AbstractRequest.relative_url_root = "/rapp"
C:&gt; sc config rails_rapp start= auto
C:&gt; net start rails_rapp
# To remove the service use: mongrel_rails service::remove -N rails_rapp
&lt;/pre&gt;

&lt;h4&gt;Permissions&lt;/h4&gt;
&lt;p&gt;Mongrel service will be running as SYSTEM or NETWORK SERVICE, You need to check/give the following permissions.&lt;p&gt;
&lt;ul&gt;
&lt;li&gt;Give FULL permission for C:\rails\rapp\temp and C:\rails\rapp\log&lt;/li&gt;
&lt;li&gt;Give FULL permission to TEMP (C:\WINDOWS\TEMP)&lt;/li&gt;
&lt;li&gt;Give FULL permission to any other folders your rails app1 writes to (e.g C:\rails\app1\public\attachments )&lt;/li&gt;
&lt;li&gt;Check Read/Execute permissions for C:\ruby\* and C:\ruby\ImageMagick-6.3.0-Q8&lt;/li&gt;
&lt;li&gt;Check Read permission Under HKEY_CLASSES_ROOT\ADODB.Connection for both the ADODB.Connection and ADODB.Connection.X.X entries # mssql only&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
 
&lt;h4&gt;Test using mongrel service&lt;/h4&gt;
&lt;p&gt;Browse to http://localhost:4004/rapp/hello/world, Note all url's are now relative to rapp, This allows multiple rails apps to be hosted behind iis&lt;/p&gt;
&lt;pre&gt;
C:&gt; iexplore.exe http://localhost:4004/rapp/hello/world 
# Should get hello world page, Rendered for the 1st time 
# Press refresh a few times, See the counter grow.
&lt;/pre&gt;

&lt;h4&gt;Now to host behind IIS&lt;/h4&gt;
&lt;p&gt;Create a virtial directory, so IIS services up the public/static portion of the site, (i.e. C:\rails\rapp\public)&lt;/p&gt;
&lt;pre&gt;
C:&gt; mkdir C:\Inetpub\Logfiles
C:&gt; inetmgr.exe # Change log file folder
  # Goto -&gt; Default Web Site -&gt; Properties -&gt; Web Site Tab -&gt; Logging properties
    Log file directory -&gt; C:\Inetpub\Logfiles

C:&gt; inetmgr.exe # Add in your application
  # Goto -&gt; Default Web Site -&gt; New -&gt; Virtual Directory -&gt; 
    Alias/Name -&gt; rapp
    Directory/Path -&gt; C:\rails\rapp\public
    Permissions -&gt; Read + Scripts + Executables
    
    # Note: Need Execute otherwise proxy/forwarding does not work !!!! 
&lt;/pre&gt;
&lt;h4&gt;Test static portion&lt;/h4&gt;
&lt;p&gt;Browse to http://localhost/rapp/index.html - You should see the standard welcome to rails page&lt;/p&gt;
&lt;pre&gt;
C:&gt; iexplore.exe http://localhost/rapp/index.html 
# Should get the "Rails Welcome aboard" 
&lt;/pre&gt;

&lt;h4&gt;Configure ISAPI_Rewrite3 to forward to Mongrel&lt;/h4&gt;
&lt;p&gt;Confiure ISAPI_Rewrite to forward all http://host/rapp/* to mongrel on http://127.0.0.1:4004/rapp/*. 
NOTE: We do not forward requests contining a full stop (.), So files like .js and .css etc will be serviced up by iis&lt;/p&gt;
&lt;pre&gt;
C:&gt; C:\Inetpub\ISAPI_Rewrite3\Helicon Manager.exe
    Click -&gt; Edit
    Enter your new rule
        RewriteProxy rapp/([^.]+)$ http://127.0.0.1:4004/rapp/$1
&lt;/pre&gt; 
&lt;p&gt;Your "C:\Inetpub\ISAPI_Rewrite3\httpd.conf" file should look something like&lt;/p&gt;
&lt;pre&gt;
# Helicon ISAPI_Rewrite configuration file
# Version 3.0.0.23
RewriteEngine on
RewriteBase /
RewriteProxy rapp/([^.]+)$ http://127.0.0.1:4004/rapp/$1
&lt;/pre&gt;
&lt;p&gt;&lt;b&gt;Rails .htaccess legacy&lt;/b&gt;&lt;br&gt;Remove/Rename the c:\rails\rapp\public\.htaccess file, 
as this is read by ISAPI_Rewrite but is designed for Apache !!! &lt;/p&gt;
&lt;pre&gt;
C:&gt; rename c:\rails\rapp\public\.htaccess c:\rails\rapp\public\apache.htaccess
&lt;/pre&gt;

&lt;h4&gt;Test mongrel/dynamic portion&lt;/h4&gt;
&lt;p&gt;Browse to http://localhost/rapp/hello/world  - You should see the Hello World with counter from last test&lt;/p&gt;
&lt;pre&gt;
C:&gt; iisreset # restart iis
C:&gt; iexplore.exe http://localhost/rapp/hello/world
# Should get hello world page, Rendered for the nth time 
&lt;/pre&gt;

&lt;h3&gt;Fininshed&lt;/h3&gt;
&lt;p&gt;You should now have a working rails application, behind IIS using Mongrel. &lt;br&gt;
To add another application simply nominate a new relative url.&lt;p&gt;

&lt;h4&gt;Multiple Applications&lt;/h4&gt;
When running multiple rails applications, set the session key to be unique for each 
instance, otherwise you will be trying to share session keys across multiple apps.
&lt;pre&gt;
C:&gt; Edit \rails\app1\controllers\application.rb
class ApplicationController &amp;lt; ActionController::Base
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key =&gt; '_&lt;b&gt;&lt;i&gt;rapp&lt;/i&gt;&lt;/b&gt;_session_id'
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-3174334067334509974?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/3174334067334509974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=3174334067334509974' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/3174334067334509974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/3174334067334509974'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/10/how-to-deploy-rails-under-iis-with.html' title='HOW TO: Rails under IIS with Mongrel and ISAPI_Rewrite3'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-1709072546077302581</id><published>2007-07-04T13:04:00.000+12:00</published><updated>2007-07-04T13:25:22.340+12:00</updated><title type='text'>A auto selector for a select "Autoselector.Local", like Autocompleter.Local</title><content type='html'>&lt;h4&gt;Background&lt;/h4&gt;
&lt;p&gt;I needed a text field to automatically select items from a select list, To assist the users when coding on a form. &lt;/p&gt; 
&lt;p&gt;Within "script.aculo" there is a similar function Autocompleter that autocompletes, given a list of possible choices, this is done client/browser side &lt;/p&gt;
&lt;h4&gt;The Solution&lt;/h4&gt;
&lt;p&gt;To develop a autoselector, this would take the text field to monitor, a list of keywords to match, and input select to update&lt;/p&gt;

&lt;h4&gt;The JavaScript Code&lt;/h4&gt;
&lt;p&gt;Place the below code into say "application.js"&lt;/p&gt;
&lt;p&gt;NOTE: This code required prototype.js, effects.js and controls.js to be included&lt;/p&gt;
&lt;pre&gt;
//========================================
// Autoselector.local 
// Contributors:
//  Murray Speight (http://mspeight.blogspot.com/)
//========================================

// Define a client side Autoselector.Local, like "Autocompleter.Local"
// Requires, prototype.js, effects.js and controls.js
//
// Parameters: id of element to watch, id to update, and array of [keyword,value] pairs 
// The keyword can be a regular expression e.g. "deep.*vein"

var Autoselector = {};
Autoselector.Local = Class.create();
Autoselector.Local.prototype = {
  initialize: function(element, update, keyvalue ) {
    this.element     = $(element); 
    if ( this.element ) {
        this.update      = $(update);  
        this.options = {};
        this.keyvalue = keyvalue;
        this.observer = null;
        this.element.setAttribute('autocomplete','off');
        observer=this.onKeyUp.bindAsEventListener(this);
        Event.observe(this.element, "keyup", observer );
     }
  },
  onKeyUp: function(event) {
    // Scan the text for keywords, using regular expressions 
    var text=this.element.value.toLowerCase();
    for (i=0;i&amp;lt;this.keyvalue.length;i++) {
      var re=new RegExp('\\b'+this.keyvalue[i][0]);
      if ( text.search(re) &amp;gt;= 0 ) {
        var newvalue = this.keyvalue[i][1];
        if ( this.update.value != newvalue ) {
          this.update.value = newvalue;
          // If has an onchange event, Call it
          if ( this.update.onchange )
            this.update.onchange.call(this);
        } 
        break;
      }
    } 
  }
}
&lt;/pre&gt;
&lt;h4&gt;Example HTML Usage&lt;/h4&gt;
&lt;p&gt;Below is an example usage. Typically the keywords/choices will be generated by the back end application. 
This is a tiedied up example of the generated html&lt;/p&gt;
&lt;p&gt;NOTE:Ensure the call to new Autoselector.Local is called after the controls are defined&lt;/p&gt;
&lt;pre&gt;
&amp;lt;input id="case_subject" maxlength="78" name="case[subject]" size="46" type="text" /&amp;gt;
 
&amp;lt;select id="case_coding_id" name="case[coding_id]" onchange="my_on_change_coding(); void 0;"&amp;gt;
  &amp;lt;option value=""&amp;gt;&amp;lt;/option&amp;gt;
  &amp;lt;option value="1"&amp;gt;Cellulitis&amp;lt;/option&amp;gt;
  &amp;lt;option value="2"&amp;gt;Deep vein thrombosis&amp;lt;/option&amp;gt;
  &amp;lt;option value="3"&amp;gt;Respiratory Infections&amp;lt;/option&amp;gt;
&amp;lt;/select&amp;gt;       

&amp;lt;script type="text/javascript"&amp;gt;
//&amp;lt;![CDATA[
  new Autoselector.Local('case_subject','case_coding_id',
       [["absces", 1], ["abces", 1], ["cellulit", 1], 
        ["dvt", 2], ["deep.*vein", 2], ["thrombo", 2], 
        ["pneum", 3], ["bromo", 3]]);
//]]&amp;gt;
&amp;lt;/script&amp;gt;
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-1709072546077302581?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/1709072546077302581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=1709072546077302581' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/1709072546077302581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/1709072546077302581'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/07/auto-selector-for-select.html' title='A auto selector for a select &quot;Autoselector.Local&quot;, like Autocompleter.Local'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-2466099071220312301</id><published>2007-06-22T16:54:00.001+12:00</published><updated>2007-06-22T16:56:24.680+12:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='ror'/><category scheme='http://www.blogger.com/atom/ns#' term='group_by'/><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><title type='text'>A better group_by "in_groups_by" for ActiveRecord</title><content type='html'>&lt;h4&gt;Background&lt;/h4&gt;
&lt;p&gt;Active record's find returns an array, you can use group_by to put the result
into a groups. However group_by returns a hash, a hash does not have any order,
When you iterate thru the hash it comes out in any order.
 
&lt;h4&gt;Better Approach&lt;/h4&gt;
&lt;p&gt;Write a function to return a array of records grouped by some critiera (Like in_groups_of).
Now you can simply iterate thru using each and each. In my implementation I have assumed the data is already ordered  &lt;/p&gt;

&lt;h4&gt;The Code&lt;/h4&gt;
&lt;pre&gt;
class Array
  def in_groups_by
    # Group elements into individual array's by the result of a block
    # Similar to the in_groups_of function.
    # NOTE: assumes array is already ordered/sorted by group !!
    curr=nil.class 
    result=[]
    each do |element|
       group=yield(element) # Get grouping value
       result &amp;lt;&amp;lt; [] if curr != group # if not same, start a new array
       curr = group
       result[-1] &amp;lt;&amp;lt; element
    end
    result
  end
end

&lt;/pre&gt;

&lt;p&gt;Go on Give it a go, Copy and paste the below code into say the bottom of "environment.rb", re-cycle the server, and try&lt;/p&gt;
&lt;h4&gt;An Example&lt;/h4&gt;
&lt;pre&gt;
def customers_grouped_by_country
  ds=Customer.find(:all, :order =&gt; :order=&gt;"county_id")
  ds.in_groups_by(&amp;:county_id)
  # or the alternative syntax 
  # ds.in_groups_by { |r| r.country_id }
end

&amp;lt;% customers_grouped_by_country.each do |group| %&amp;gt;
  &amp;lt;h1&amp;gt;Country &amp;lt;%= group[0].country_id&amp;gt;&amp;lt;/h1&amp;gt;
  &amp;lt;% group.each do |e| %&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;%= e.name %&amp;gt;&amp;lt;/p&amp;gt;
  &amp;lt;% end %&amp;gt;
&amp;lt;% end &amp;gt;

&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-2466099071220312301?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/2466099071220312301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=2466099071220312301' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/2466099071220312301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/2466099071220312301'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/06/better-groupby-ingroupsby-for.html' title='A better group_by &quot;in_groups_by&quot; for ActiveRecord'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-822290739071824506</id><published>2007-06-21T10:40:00.000+12:00</published><updated>2007-06-21T10:55:46.798+12:00</updated><title type='text'>How to E-Mail rails/ms-sql log files with Windows XP/2003 using CDO.Message</title><content type='html'>&lt;h4&gt;Intro&lt;/h4&gt;
&lt;p&gt;I needed to monitor my rails app admin tasks, this is hosted on Windows Server 2003. 
The most convienient way was to run a batch (.cmd) script to perform various tasks and 
e-mail myself the outcome. Windows does not have a built in utility to do this, So Wrote one.&lt;/p&gt;
&lt;p&gt;Since Im a rails developer, the obvious choice of language (apart from ruby) was JavaScript, 
And use windows cscript utility. This worked a treat&lt;/p&gt;

&lt;h4&gt;How it works&lt;/h4&gt;
&lt;p&gt;Windows 2000+, and XP provides CDO.Message ActiveX controls to send e-mails, All you need is to give it 
a remote smtp server (that allows forwarding), Set the body/attachments  and you are away.
&lt;p&gt;What it does is simply send a file as an attachment or as the body of the e-mail, given an sever&lt;/a&gt;
&lt;h4&gt;Usage&lt;/h4&gt;
&lt;pre&gt;
  usage: sendmail.js to-email "subject" [ "body" ]

options:  /smtp smtp.xxx.co.nz - Smtp address of server 
          /port nn - Smtp port defaults to 25  
          /cc e-mailaddress 
          /from email - defaults to username@computername.local
          /attach filepath - attach the file  
          /body filepath  - use file as body of the mesasge 
          
   note: Note filepath must be fully qualified          

&lt;/pre&gt;
&lt;p&gt;Example Usage&lt;/p&gt;    
&lt;pre&gt;
C:&gt; cscript /nologo sendmail.js /smtp smtp.isp.com
                        /body "fullpath\admin.log" 
                        toemail@somewhere.com 
                        "[RAILS-ADMIN] Log of admin tasks"
&lt;/pre&gt;
&lt;h4&gt;The Code&lt;/h4&gt;
Click here 
&lt;a href="javascript:window.open( 'http://murray.speight.googlepages.com/sendmail_js.html' );void 0;"&gt;sendmail.js&lt;/a&gt;
to view the code&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-822290739071824506?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/822290739071824506/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=822290739071824506' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/822290739071824506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/822290739071824506'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/06/how-to-e-mail-railsms-sql-log-files.html' title='How to E-Mail rails/ms-sql log files with Windows XP/2003 using CDO.Message'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-497291172338450049</id><published>2007-06-19T13:43:00.000+12:00</published><updated>2007-06-19T13:44:11.511+12:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><category scheme='http://www.blogger.com/atom/ns#' term='autocomplete'/><title type='text'>Disable Browsers Autocomplete on a Rails Form</title><content type='html'>&lt;h4&gt;Intro&lt;/h4&gt;
&lt;p&gt;Autocomplete on a form can cause the observe_field not to fire (I was using on =&gt; keyup, i am going to change to on =&gt; blur  and test)&lt;/p&gt;
&lt;p&gt;Also the users get confused if too many things on a form, start autocompeting&lt;/p&gt;

&lt;h4&gt;The Solutuion&lt;/h4&gt;
&lt;p&gt;Simply disable autocomplete, Tested on IE/Firefox. This can be done at the form level &lt;/p&gt;
&lt;pre&gt;
&amp;lt;% form_tag( {:action =&gt; 'post'}, { :autocomplete =&gt; :off } ) do %&amp;gt;
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-497291172338450049?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/497291172338450049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=497291172338450049' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/497291172338450049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/497291172338450049'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/06/disable-browsers-autocomplete-on-rails.html' title='Disable Browsers Autocomplete on a Rails Form'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-8504022425123293532</id><published>2007-06-19T13:34:00.000+12:00</published><updated>2007-06-19T13:35:41.018+12:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><category scheme='http://www.blogger.com/atom/ns#' term='fastcgi'/><category scheme='http://www.blogger.com/atom/ns#' term='iis'/><title type='text'>Running Rails Apps More Reliability under IIS</title><content type='html'>&lt;h4&gt;Intro&lt;/h4&gt;
&lt;p&gt;I have been attempting to get the new &lt;a href="javascript:window.open('http://www.iis.net/default.aspx?tabid=1000051');void 0;"&gt;FastCGI for IIS&lt;/a&gt; preview to run on IIS5/6 as detailed previously.&lt;/p&gt;
&lt;p&gt;Yes it runs just, But is unrelaible when you perform http posts. However the exersise had one good side effect. &lt;/p&gt; 

&lt;h4&gt;The Good News&lt;/h4&gt;
&lt;p&gt;The blog at &lt;a href="javascript:window.open('http://mvolo.com/blogs/serverside/archive/2007/02/18/10-steps-to-get-Ruby-on-Rails-running-on-Windows-with-IIS-FastCGI.aspx');void 0;"&gt;10 steps to get Ruby on Rails running on Windows with IIS FastCGI&lt;/a&gt;
detailed a change you need to make to the cgi.rb. because IIS does not support No Parsed Headers (NPH)&lt;/p&gt;
&lt;p&gt;Once this change was in place, My web site using the older fastcgi runs &lt;b&gt;much more reliably&lt;/b&gt;&lt;/p&gt;
&lt;pre&gt;
# The changes is to lib\ruby\1.8\cgi.rb, 
# is to comment out the refereence to IIS
 
Line 559: if options.delete("nph") &lt;b&gt;#&lt;/b&gt; or /IIS/n.match(env_table['SERVER_SOFTWARE'])
&lt;/pre&gt;
&lt;h4&gt;The Bad News&lt;/h4&gt;
&lt;p&gt;I would perferr to use the new FastCGI for IIS when it comes out, My problem issue is detailed on the &lt;a href="javascript:window.open('http://forums.iis.net/1103.aspx');void 0;"&gt;IIS FastCGI Handler Forum&lt;/a&gt;
hopefully some one will details a solution. 
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-8504022425123293532?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/8504022425123293532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=8504022425123293532' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/8504022425123293532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/8504022425123293532'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/06/running-rails-apps-more-reliability.html' title='Running Rails Apps More Reliability under IIS'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-4116665437540434759</id><published>2007-06-08T14:18:00.000+12:00</published><updated>2007-06-08T14:20:31.192+12:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ado'/><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='sql server'/><category scheme='http://www.blogger.com/atom/ns#' term='ADOExplorer'/><category scheme='http://www.blogger.com/atom/ns#' term='db'/><title type='text'>ADO Explorer A sql tool for Access/MS-SQL/VFP</title><content type='html'>&lt;p&gt;I just spent the last day converting data from a legacy access application to My Rails app 
(back end "dictated" db  ms-sql), It was a tedious exercuise using Access and MS's Managment Studio.&lt;/p&gt;
 
&lt;p&gt;Years ago developed an application that could access any ADO database using a common interface. 
So I developed it again, but made it better. Conversion was a breeze. This tool affectionately called
ADOExploer is available here &lt;a href="http://murray.speight.googlepages.com/adoexplorer"&gt;ADO Explorer Page&lt;/a&gt;. Feedback so-far has been good, enjoy&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-4116665437540434759?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/4116665437540434759/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=4116665437540434759' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/4116665437540434759'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/4116665437540434759'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/06/ado-explorer-sql-tool-for-accessms.html' title='ADO Explorer &lt;small&gt;A sql tool for Access/MS-SQL/VFP&lt;/small&gt;'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-9035843703892896926</id><published>2007-05-31T11:19:00.000+12:00</published><updated>2007-05-31T11:23:24.674+12:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><category scheme='http://www.blogger.com/atom/ns#' term='ie'/><category scheme='http://www.blogger.com/atom/ns#' term='backspace'/><category scheme='http://www.blogger.com/atom/ns#' term='disable'/><title type='text'>How to: Disable Backspace key in IE and Firefox</title><content type='html'>&lt;h4&gt;The problem&lt;/h4&gt;
&lt;p&gt;When a user presses the Backspace key on a page in Internet Explorer (IE) presses the back button, this 
is very frustrating when you have a form on the screen and accidently press backspace. And loose your page.
&lt;/p&gt;
&lt;p&gt;I watched one of my users enter data on a form, but was correcting some 
data in a text box and pressed backspace once too many times, and IE when BACK!!&lt;/p&gt;
&lt;p&gt;Firefox is much better (at least it does not do a BACK on a text input), but it does do a back on 
other fields (e.g. a select)&lt;/p&gt;
&lt;h4&gt;The fix&lt;/h4&gt;
&lt;p&gt;Trap the onkeydown to ignore backspace. The code below also disables Enter unless on the Submit button&lt;/p&gt;
&lt;h5&gt;The Code&lt;/h5&gt;
&lt;pre&gt;
&amp;lt;script type="text/javascript"&amp;gt;

// Trap Backspace(8) and Enter(13) - 
// Except bksp on text/textareas, enter on textarea/submit

if (typeof window.event != 'undefined') // IE
  document.onkeydown = function() // IE
    {
    var t=event.srcElement.type;
    var kc=event.keyCode;
    return ((kc != 8 &amp;&amp; kc != 13) || ( t == 'text' &amp;&amp;  kc != 13 ) ||
             (t == 'textarea') || ( t == 'submit' &amp;&amp;  kc == 13))
    }
else
  document.onkeypress = function(e)  // FireFox/Others 
    {
    var t=e.target.type;
    var kc=e.keyCode;
    if ((kc != 8 &amp;&amp; kc != 13) || ( t == 'text' &amp;&amp;  kc != 13 ) ||
        (t == 'textarea') || ( t == 'submit' &amp;&amp;  kc == 13))
        return true
    else {
        alert('Sorry Backspace/Enter is not allowed here'); // Demo code
        return false
    }
   }
&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;h5&gt;FireFox Fix&lt;/h5&gt;
&lt;p&gt;You can disable the backspace action in firefox by going to "about:config" and changing "browser.backspace_action" to something other than "0" or "1", e.g. "2"&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-9035843703892896926?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/9035843703892896926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=9035843703892896926' title='31 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/9035843703892896926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/9035843703892896926'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/05/how-to-disable-backspace-in-ie-and.html' title='How to: Disable Backspace key in IE and Firefox'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>31</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-4070546413647542283</id><published>2007-05-29T10:22:00.000+12:00</published><updated>2007-12-20T09:45:39.658+13:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='ror'/><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><category scheme='http://www.blogger.com/atom/ns#' term='fastcgi'/><category scheme='http://www.blogger.com/atom/ns#' term='iis'/><title type='text'>How to: Run Multiple Rails Apps under IIS using fast Cgi</title><content type='html'>&lt;p&gt;I have found iis/aspi/fast cgi to be un-reliable, seems to crash once a week, 
I think it is related to a specific size of a post, But have not had the time to track it down&lt;/p&gt;

&lt;h4&gt;Update - Oct - 2007 &lt;/h4&gt;
&lt;p&gt;&lt;b&gt;Thanks this page seems to be quite popular&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;A much better/reliable solution is to use IIS with Mongrel behind it,&lt;br&gt;
Check out &lt;a href="http://mspeight.blogspot.com/2007/10/how-to-deploy-rails-under-iis-with.html"&gt; HOW TO DEPLOY: Rails under IIS with ISAPI_Rewrite3/Mongrel&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;

&lt;h4&gt;Update - Dec - 2007 &lt;/h4&gt;
&lt;p&gt;&lt;b&gt;I have updated this entry for rails 2.0 &lt;br&gt;
Check out &lt;a href="http://mspeight.blogspot.com/2007/12/rails-v20-with-iis-mssql-isapirewrite3.html"&gt;Rails v2.0 with IIS, ISAPI_Rewrite3, Mongrel&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;
 
&lt;h4&gt;Disclaimer&lt;/h4&gt;
&lt;p&gt;First off I dont recommend it, But if you must as dictated by an outside source here are the steps.&lt;/p&gt;
&lt;p&gt;There are severl source's of information around but none that give and how/who with step-step details.&lt;/p&gt;
&lt;p&gt;After accessing various sources, I finally got IIS to work "reasonably reliably", PS: Included are tips for trouble shooting permissions issues.&lt;/p&gt;

&lt;h4&gt;Background - How do you get IIS to talk to rails&lt;/h4&gt;
&lt;p&gt;When IIS sees an url like &lt;b&gt;http://host/something.asp?search=abc&lt;/b&gt;, It looks up and 
sees if there is an application (dll/exe) associated with the extension &lt;b&gt;.asp&lt;/b&gt;, 
if there is then it passes the request to the application associated with the extension.&lt;/p&gt;
&lt;p&gt;So in order to run a ruby application behind iss, we need to associate a extension 
with "rubyw.exe" for each rails app, the extension can be anything, lets call this ".rap1" (Ruby Application 1).&lt;/p&gt;
&lt;p&gt;Below details that steps to do this &lt;/p&gt;

&lt;h5&gt;STEP 1 - Rewrite The Url&lt;/h5&gt;
&lt;p&gt;We need to give IIS a url that looks something like 
http://host/something.rap1?information-for-rails-app,&lt;/p&gt; 
&lt;p&gt;But Rails generates nice looking urls, e.g. http://host/app1/controller/method, 
IIS allows you to re-write URL's,&lt;/p&gt; 
&lt;p&gt;So we take http://host/app1/controller/method?etc=1 and convert 
it to http://host/something.rap1?opnq=/controller/method?etc=1&lt;/p&gt;
&lt;p&gt;To do this we grap &lt;a href="http://www.codeplex.com/IIRF"&gt;"Ionic's Isapi Rewrite for IIS"&lt;/a&gt;  (details below)&lt;/p&gt;

&lt;h5&gt;STEP 2 - Rewrite it back for Rails&lt;/h5&gt;
&lt;p&gt;But the Rails app is expecting "/controller/method?etc=1" not "opnq=/controller/method?etc=1", 
So you need to re-write it back in to a nice url inside rails.&lt;/p&gt;
&lt;p&gt;To do this we patch ActionController::AbstractRequest.request_uri (see app1/lib/action_controller_request_ext.rb)&lt;/p&gt;
 
&lt;h5&gt;STEP 3 - app prefix the Url&lt;/h5&gt;

&lt;p&gt;Since we will be running multiple apps, we need to prefix the urls rails generates with /app1, 
to distinguish each application (see app1/lib/environment.rb, ActionController::AbstractRequest.relative_url_root = "/app1")&lt;/p&gt; 

&lt;h4&gt;Background - Running Ruby from IIS&lt;/h4&gt;

&lt;p&gt;OK lets assume we have the url's ok, Next step is to actually run ruby (rubyw.exe) to get the app to work.&lt;/p&gt;
&lt;p&gt;We could run rubyw directly as a cgi, but this would mean for each request, rails is started run and closed, VERY VERY Slow.&lt;/p&gt; 
&lt;p&gt;So we take &lt;a href="http://www.caraveo.com/fastcgi/"&gt;"Shane Careveo's Fast CGI"&lt;/a&gt; dll which 
keeps the rails app running and simply feeds it new requests&lt;/&gt;

&lt;h5&gt;STEP 4 - Map your extension &lt;/h5&gt;
&lt;p&gt;Using IIS Map the .rap1 extension to call the isapi_fcgi.dll. (which will call rubyw)&lt;/p&gt;
&lt;h5&gt;STEP 5 - Configure fcgi to run Ruby&lt;/h5&gt;
&lt;p&gt;Tell the isapi_fcgi.dll what ruby application to run when it gets called with a .rap1 extension, (details below)&lt;/p&gt;
&lt;p&gt;You will also need to install ruby code, to deal with how isapi_fcgi disptaches.  (see dispatch.fcgi) &lt;/p&gt;  
&lt;h5&gt;STEP 6 - Permission&lt;/h5&gt;
&lt;p&gt;Fix up permissions as ruby will be run as a limited user.&lt;/p&gt;

&lt;h5&gt;Misc Notes&lt;/h5&gt;
&lt;p&gt;You can replace "opnq" in the url, with anything you like, I kept it the same as used by RORIIS, 
also the "something" can be any name you want, I called it fastcgi, but all we need is for IIS to look at the extension .rap1 and
call isapi_fcgi.dll that in turn runs ruby!!!&lt;/p&gt; 
 

&lt;h4&gt;Install Ruby/Rails MSSQL Software&lt;/h4&gt;

&lt;p&gt;The boring bit, This section you can skip, But was included for completeness &lt;/p&gt; 

&lt;h5&gt;Install MSSQL&lt;/h5&gt; 
&lt;pre&gt;
&gt; dotnetfx.exe  # Install .Net Frame work 2.0 
&gt; SQLEXPR32-SP2.EXE # MS SQl Server 2005 EXPRESS 
  # Install to "C:\Program Files\Microsoft SQL Server 2005 EXPRESS"
  # Used Named Instance "SQLEXPRESS"
  # Used mixed authentication, "sa" passsword "yourchoice"
&gt; SQLServer2005_SSMSEE.msi # Install MS Sql Server Managment Studio
&lt;/pre&gt;

&lt;h5&gt;Install Ruby + Gems&lt;/h5&gt; 
&lt;pre&gt;
&gt; mkdir C:\ruby
&gt; run ruby185-21.exe # Install ruby 
  # Select Install "Ruby" and "Enable RubyGems"
  # Install to "C:\ruby 
  # Check C:\ruby\bin to your everyones path !!
  
  # download rubygems, un-zip and run setup.rb
&gt; ruby setup.rb # Install ruby gems
&lt;/pre&gt;

&lt;h5&gt;Install Rails&lt;/h5&gt;
&lt;pre&gt;
&gt; cd C:\ruby
&gt; gem install --include-dependencies rails # Wait may take a while !!!
&gt; gem install --include-dependencies win32-service # pick the most recent mswin32 !!
# gem install --include-dependencies mongrel # pick the win32 pre-built
# gem install --include-dependencies mongrel_service  
&lt;/pre&gt;


&lt;h5&gt;Install MSSQL Drivers&lt;/h5&gt;
&lt;pre&gt;
# download ruby-dbi, un-zip and run setup.rb
&gt; ruby setup.rb config --with=dbd_ado
&gt; ruby setup.rb setup
&gt; ruby setup.rb install
# Patch  sqlserver_adapter.rb (See Rails Ticket #7733)
&gt; cd C:\ruby\lib\ruby\gems\1.8\gems\activerecord-1.15.3\
                  lib\active_record\connection_adapters
&gt; edit sqlserver_adapter.rb
# Line 28x: "=~ /null/ ? nil"   ==&gt; "=~ /null/&lt;b&gt;i&lt;/b&gt;&gt; ? nil"  
#    Case insensitive match on the word null
&lt;/pre&gt;


&lt;h5&gt;Install other gems (e.g. RMagick / Faster CSV)&lt;/h5&gt;
&lt;pre&gt;
# download ImageMagick and run setup.rb
&gt; ImageMagick-6.3.0-7-Q8-windows-dll.exe 
# Tick [x] Update executable search path.

# download rmagick gem and install
&gt; gem install rmagick --local
# Note: Documentation is in C:\ruby\lib\ruby\gems\
#    1.8\gems\rmagick-1.14.1-win32\doc\index.html

# download fastercsv gem and install
&gt; gem install fastercsv --local
&lt;/pre&gt;

&lt;h5&gt;Create Rails Application and check operation&lt;/h5&gt;
Create a basic rails app, for testing. I assume c:\rails is where your rails apps will be placed
&lt;pre&gt;
&gt; mkdir C:\rails
&gt; cd rails
&gt; rails app1 # Create rails app called app1
&gt; ruby script/server # Run WebBrick to test 
&gt; iexplore.exe http://localhost:3000 
  # Should get welcome page
&gt; iexplore.exe http://localhost:3000/controller/etc
  # You should see routine error, no route found... 
  # exception from the from the rails app  
&gt; Ctrl+break
&gt; exit 
&lt;/pre&gt;

&lt;h4&gt;The Details&lt;/h4&gt;
&lt;p&gt;The original source for set-up is as follows. Thanks to all.&lt;/p&gt; 
&lt;p&gt;&lt;a href="http://www.codeplex.com/RORIIS"&gt;"Ruby On Rails For IIS Fast-CGI"&lt;/a&gt;  (This contains all the files menthoned)&lt;/p&gt;

&lt;p&gt;&lt;b&gt;NOTE:&lt;/b&gt; If did not install "ROR4IISFCGI_1.0.5.exe", As the install is for a single rails application, 
Simply Open the file with say 7-Zip and extract. I used this file simply as the source. 
For each step I have detailed only the final destionation folder&lt;/p&gt;

&lt;p&gt;The set-up process detailed below, assumes the folllowing.
&lt;ul&gt;
&lt;li&gt;Ruby is installed in c:\ruby&lt;/li&gt;
&lt;li&gt;Your application is called "app1" and resides in c:\rails\app1, The extension nominated for is .rap1&lt;/li&gt;
&lt;li&gt;Iis has C:\Inetpub as its base&lt;/li&gt;
&lt;li&gt;Windows is C:\Windows&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Install/Configure IaspiRewriter&lt;/h4&gt; 
&lt;h5&gt;The following files are installed/edited&lt;/h5&gt;
&lt;pre&gt;
Inetpub
Inetpub\IsapiRewrite4.dll
Inetpub\IsapiRewrite4.ini # Copied and Edited
rails
rails\app1
rails\app1\lib
rails\app1\lib\action_controller_request_ext.rb
rails\app1\config\environment.rb # Edited  
rails\app1\config\routes.rb # Edited  
&lt;/pre&gt;
&lt;h5&gt;Rewrite The Url&lt;/h5&gt;
&lt;pre&gt;
# copy/install Inetpub\IsapiRewrite4.dll, Inetpub\IsapiRewrite4.ini
&gt; inetmgr.exe # Add url rewriter 
  # Goto:  Default Web Site -&gt; Properties -&gt; ASPI Filters -&gt; Add 
    Name: IsapiRewrite4
    Exe: C:\Inetpub\IsapiRewrite4.dll  
&gt; cd C:\Inetpub
&gt; edit IsapiRewrite4.ini
  # Add the following rule to take urls with /app1 to call fastcgi.rap1 
  RewriteRule ^/app1(/[^.]+)$ /fastcgi.rap1?opnq=$1
  # Note: urls, with a '.' in them are not mapped. 
  # This is cool, because iis will handel serving up the the 
  # public images/css etc (see later)
&gt; edit routes.rb  # If using Web Services. Change the .wsdl to _wsdl 
  as now cannot have a "." in a url destined for rails
  # change ':controller/service.wsdl' =&gt; ':controller/service_wsdl'

&lt;/pre&gt;
&lt;h5&gt;Rewrite it back for Rails&lt;/h5&gt;
&lt;pre&gt;
# copy/install rails\app1\lib\action_controller_request_ext.rb
&gt; cd C:\rails\app1\config
&gt; edit environment.rb
  # Add the following line to the section titled 
  # "Include your application configuration below"
  require 'action_controller_request_ext.rb'
&lt;/pre&gt;
&lt;h5&gt;app1 prefix the Url&lt;/h5&gt;
&lt;pre&gt;
&gt; cd C:\rails\app1\config
&gt; edit environment.rb
  # Add the following line to the section titled 
  # "Include your application configuration below"
  ActionController::AbstractRequest.relative_url_root = "/app1" 
      if ENV['RAILS_ENV'] == 'production'
&lt;/pre&gt;
 
&lt;h4&gt;Install/Configure FastCGI&lt;/h4&gt; 
&lt;h5&gt;The following files are installed/edited&lt;/h5&gt;
&lt;pre&gt;
Inetpub
Inetpub\isapi_fcgi.dll
Inetpub\wwwroot
Inetpub\wwwroot\fastcgi.rap1 # Created manually
rails
rails\app1
rails\app1\FastCGI.reg # Created manually 
rails\app1\public
rails\app1\public\dispatch.fcgi
ruby
ruby\lib
ruby\lib\ruby
ruby\lib\ruby\site_ruby
ruby\lib\ruby\site_ruby\1.8
ruby\lib\ruby\site_ruby\1.8\fcgi.rb
ruby\lib\ruby\site_ruby\1.8\i386-msvcrt
ruby\lib\ruby\site_ruby\1.8\i386-msvcrt\fcgi.so
Windows
Windows\System32
Windows\System32\libfcgi.dll
Windows\System32\msvcp71.dll # if not already present
Windows\System32\msvcr71.dll # if not already present
&lt;/pre&gt;

&lt;h5&gt;Configure fastcgi to run Ruby&lt;/h5&gt;
&lt;p&gt;Place settings in the register to tell isapi_fcgi which ruby app to run based on the file extension it is called as &lt;/p&gt;
&lt;pre&gt;
&gt; copy files as indicated above ...
&gt; echo "# fastcgi" &gt; C:\Inetpub\wwwroot\fastcgi.rap1 # Simply a dummy file
&gt; edit/create C:\rails\app1\FastCGI.reg
# Place the following in the file. 

# These registry settings tell isapi_fcgi.dll what rails 
# app to run based on what file extension it is called with

[HKEY_LOCAL_MACHINE\SOFTWARE\FastCGI]
[HKEY_LOCAL_MACHINE\SOFTWARE\FastCGI\.rap1]
@=""
"BindPath"="Rails-FCGI-app1"
"AppPath"="C:\\ruby\\bin\\rubyw.exe"
"Args"="C:\\rails\\app1\\public\\dispatch.fcgi"
"Environment"=&lt;small&gt;hex:52,41,49,4c,53,5f,45,4e,56,3d,70,72,6f,64,75,63,74,69,6f,6e,0d,0a,00&lt;/small&gt;
"StartServers"=dword:00000003
"IncrementServers"=dword:00000001
"MaxServers"=dword:00000006
"MaxProcMem"=dword:00000064
"Timeout"=dword:00000258

# The key "Environment" contains "RAILS_ENV=production\r\n\0" 

&gt; cd C:\rails\app1\
&gt; FastGGI.reg # Load details into the widows registry
&lt;/pre&gt; 

&lt;h5&gt;Configure/Map your extension IIS&lt;/h5&gt;
&lt;p&gt;We will Map a Virtual directory to our application, Map the extension .rap 1 to our application&lt;/p&gt;

&lt;pre&gt;
&gt; inetmgr.exe # Add in your application to Virtual dir 
  # Goto:  Default Web Site -&gt; New Virtual Directory -&gt; 
    Name -&gt; app1
    Path -&gt; C:\rails\app1\public
    Permissions -&gt; Read
&gt;  netmgr.exe # Add in your application extension .rap1
  # Goto:  Default Web Site -&gt; Properties -&gt; Home Directory 
         -&gt; Configration -&gt; Mapping -&gt; Add
    Executable -&gt; C:\Inetpub\isapi_fcgi.dll
    Extension -&gt; ".rap1"  # with the "."
    Script Engine -&gt; Ticked
    Check the File Exists -&gt; Ticked
  # If the OK button is gray, (bug in IIS 5.1)
      click on the Executable File Name a 2nd time 
  # Ensure Cache ISAP Extensions is Ticked 
&lt;/pre&gt;
  
&lt;h5&gt;Configure Permissions (the messy bit)&lt;/h5&gt;

&lt;p&gt;Your app wont run yet, as rubyw will be running as a restricted user. Perform 
the following steps. We will set-up a group called "Rails" and assign the IIS 
process user  "IWAM_&lt;i&gt;computername&lt;/i&gt;" to this group. &lt;/p&gt;
&lt;pre&gt;
&gt; compmgmt.msc
  # Goto: Local Users and Groups -&gt; New Group -&gt; Rails
  # Add new Rails group (with no members)   
&gt; compmgmt.msc
  # Goto: Local Users and Groups -&gt; IWAM_&lt;i&gt;computername&lt;/i&gt; -&gt; 
  #       Properties -&gt; Member Of -&gt; Add -&gt; Rails
&lt;/pre&gt;

&lt;p&gt;Configure iis to run application's as the local user "IWAM_&lt;i&gt;computername&lt;/i&gt;". This makes managing permissions simpler.&lt;d/p&gt;
&lt;pre&gt;
&gt; inetmgr.exe 
  # Under Server 2003+ 
    # Goto:  Application Pools -&gt; 
       DefaultAppPool -&gt; Properties -&gt; Identiry 
    # Change to "IWAM_&lt;i&gt;computername&lt;/i&gt;" 
  # Under XP 
    # Goto:  Default Web Site  -&gt;  Properties -&gt;
         Home Directory -&gt; Identiry 
    # Application protection to "Medium (Pooled)"" 
&lt;/pre&gt;

&lt;p&gt;Server 2003+ only, Configure IIS to accept the dll's and rubyw.exe application&lt;/p&gt; 
&lt;pre&gt;
# Under Server 2003+ (Only)
&gt; inetmgr.exe  # Set permissions on applications
  # Goto:  Web Server Extension -&gt; Add Web Server Extension 
    Name: Rails
    Files: Inetpub\IsapiRewrite4.dll, 
           Inetpub\isapi_fcgi.dll, 
           Windows\System32\libfcgi.dll, 
           C:\ruby\bin\rubyw.exe
    Status: Allowed
&lt;/pre&gt;

&lt;h5&gt;Set premissions on the required files/dirs for the "Rails" group&lt;/h5&gt;

&lt;p&gt;Dont forget this step otherwise your application will not run !!!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Give FULL permission for C:\rails\app1\temp and C:\rails\app1\log&lt;/li&gt;
&lt;li&gt;Give FULL permission to TEMP (C:\WINDOWS\TEMP)&lt;/li&gt;
&lt;li&gt;Give FULL permission to any other folders your rails app1 writes to (e.g C:\rails\app1\public\attachments ) &lt;/li&gt;
&lt;li&gt;Check Read/Execute permissions for all the .dll's menthoned above and rubyw.exe&lt;/li&gt;
&lt;li&gt;Check Read permission Under HKEY_CLASSES_ROOT\ADODB.Connection for both the ADODB.Connection and ADODB.Connection.X.X entries # mssql only&lt;/li&gt;
&lt;li&gt;Check Read permission Under HKEY_LOCAL_MACHINE\SOFTWARE\FastCGI # this should be ok&lt;/li&gt;
&lt;/ul&gt;

  


&lt;h4&gt;Test It&lt;/h4&gt; 
&lt;p&gt;Perform the following steps to test it works.&lt;/p&gt; 

&lt;p&gt;&lt;b&gt;Ist check your app still works with WebBrick (see above Installing Ruby etc)&lt;/b&gt;&lt;/p&gt;
 
&lt;pre&gt;
&gt; iisreset.exe # Re-start iis
&gt; iexplore.exe http://localhost/app1/controller/etc
# You should see routine error, no route found... 
# If so you have an exception Message from the Rails app, cool !!! 
# If you get fast cgi error or page not found, 
#        check out trouble shooting. 
&lt;/pre&gt;

&lt;h4&gt;Configure Your Second Application&lt;/h4&gt;

&lt;p&gt;Simply repeat the steps above (that relate to a specific application) for your application. 
Assgning your own name and extension.&lt;/p&gt;

&lt;p&gt;Simply change "app1" to your application name and".rap1" to your nominated extension&lt;/p&gt;

&lt;p&gt;&lt;i&gt;I would not recommend using .asp/.aspx extension, quite yet, mind you with ruby/rails going so well, it wont be long before the .aspx extension will become un-used. :-) &lt;/i&gt;&lt;/p&gt; 

&lt;p&gt;NOTE: Do make sure you change the "BindPath"="Rails-FCGI-app1" in the registry for fast CGI
for each application, otherwise you may end up with one app's url going to another.&lt;/p&gt;   
    
&lt;h4&gt;Trouble shooting&lt;/h4&gt; 
&lt;p&gt;Some trouble shooting tips.&lt;/p&gt;   

&lt;h5&gt;First off, Does rubyw start within iis.&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Grab "Process explorer" from &lt;a href="http://www.sysinternals.com"&gt;sysinternals&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;run "procexp.exe"&lt;/li&gt;
&lt;li&gt;Right click headings and choose select columns, Add "User Name"&lt;/li&gt; 
&lt;li&gt;Reset iis. (iisreset.exe)&lt;/li&gt;
&lt;li&gt;navigate to  http://localhost/app1/controller/etc&lt;/li&gt;  
&lt;li&gt;watch the dllhost.exe within svchost.exe,&lt;/li&gt;
&lt;ul&gt; 
&lt;li&gt;does rubyw.exe appear then disappear, If so possibly a permissions thing, does the rubyw.exe user, have permissions to all the files.&lt;/li&gt;
&lt;li&gt;It does not appeara Check the fcgi set-up. &lt;/li&gt;
&lt;/ul&gt; 
&lt;/ul&gt; 

&lt;h5&gt;Try running your app as a restricted user.&lt;/h5&gt;   

&lt;p&gt;Try the following to run your app as a restricted user. It might highlight some things&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a user called IWAM_TEST (give it a password)&lt;/li&gt; 
&lt;li&gt;Remove IWAM_TEST from the Users group&lt;/li&gt;
&lt;li&gt;Add IWAM_TEST to the Rails group&lt;/li&gt; 
&lt;li&gt;Now Run your app as IWAM_TEST using WebBrick&lt;/li&gt;
&lt;pre&gt;
&gt; runas /user:IWAM_TEST cmd 
# You should get another cmd window as this user, 
&gt; env 
# Look at the env, look ok. 
&gt; cd \rails\app1
&gt; ruby script/server
# Look at the output, Does it say "unable to access log file" 
# If so fix permissions

Navigate to http://localhost:3000/controller/etc

# Any more messages
&gt; Ctrl+break # break out of WebBrick
&gt; exit  

&lt;/pre&gt;
&lt;/ul&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;I hope this write up helps some. It helped me. &lt;/p&gt;   

&lt;p&gt;I know there is not much documentation on multiple apps and IIS.&lt;/p&gt;

&lt;p&gt;I have done it, but think IIS -&gt; Apache -&gt; Mongrel would be a better choice.&lt;/p&gt;

&lt;p&gt;All comments welcome&lt;/p&gt;

&lt;h4&gt;An Update&lt;/h4&gt;
There is one small change you need to make to cgi.rb to make fastcgi more reliable. 
Check out &lt;a href="http://mspeight.blogspot.com/2007/06/running-rails-apps-more-reliability.html"&gt;Running Rails Apps More Reliability under IIS&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-4070546413647542283?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/4070546413647542283/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=4070546413647542283' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/4070546413647542283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/4070546413647542283'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/05/how-to-run-multiple-rails-apps-under.html' title='How to: Run Multiple Rails Apps under IIS using fast Cgi'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2909074750209490543.post-6523361913597702175</id><published>2007-05-29T10:21:00.001+12:00</published><updated>2007-05-29T10:21:29.358+12:00</updated><title type='text'>How to: Fix up Blogger Template To Utilize The Full Screen</title><content type='html'>&lt;h4&gt;Intro&lt;/h4&gt;
&lt;p&gt;Blogger.com's template's (well the one I choose) uses floating divs of fixed width, 
This may be ok for some, but for those of us with screens larger the 640x480 a lot of space is wasted. &lt;/p&gt;

&lt;p&gt;So I removed the floating divs and placed in a table, nice and simple and looks great&lt;/p&gt;

&lt;h5&gt;Changes to html template are as follow:-&lt;/h5&gt; 

&lt;pre&gt;

#outer-wrapper {
  &lt;b&gt;&lt;s&gt;width: 660px;&lt;/s&gt;&lt;/b&gt;
  &lt;i&gt;etc ...&lt;/i&gt;
  }


#main-wrapper {
  &lt;b&gt;&lt;s&gt;float:left;&lt;/s&gt;&lt;/b&gt;
  overflow:hidden;
  &lt;b&gt;&lt;s&gt;width:410px;&lt;/s&gt;&lt;/b&gt;
}

#sidebar-wrapper {
  &lt;b&gt;&lt;s&gt;float:right;&lt;/s&gt;&lt;/b&gt;
  overflow:hidden;
  width: &lt;b&gt;&lt;s&gt;220px;&lt;/s&gt;&lt;/b&gt; &lt;b&gt;240px;&lt;/b&gt;
}

&lt;i&gt;etc ...&lt;/i&gt;

&lt;b&gt;&amp;lt;table&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td valign="top"&amp;gt;&lt;/b&gt;
&amp;lt;div id="main-wrapper"&amp;gt;

&lt;i&gt;etc ...&lt;/i&gt;

&lt;b&gt;&amp;lt;/td&amp;gt;
&amp;lt;td valign="top"&amp;gt;&lt;/b&gt;
&amp;lt;div id="sidebar-wrapper"&amp;gt;

&lt;i&gt;etc ...&lt;/i&gt;

&lt;s&gt;&lt;b&gt;&amp;lt;div class="clear"&amp;gt;&lt;/b&gt;&lt;/s&gt;
&lt;b&gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;&lt;/b&gt;
&amp;lt;/div&amp;gt; &amp;lt;!-- end content-wrapper --&amp;gt;
&amp;lt;div id="footer-wrapper"&amp;gt;

&lt;/pre&gt;

&lt;h4&gt;Additional Changes&lt;/h4&gt;
&lt;p&gt;I also added my own .body h4, h5 and pre styles to the ccs, to gives a much nicer look&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2909074750209490543-6523361913597702175?l=mspeight.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mspeight.blogspot.com/feeds/6523361913597702175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2909074750209490543&amp;postID=6523361913597702175' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/6523361913597702175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2909074750209490543/posts/default/6523361913597702175'/><link rel='alternate' type='text/html' href='http://mspeight.blogspot.com/2007/05/how-to-fix-up-blogger-template-to.html' title='How to: Fix up Blogger Template To Utilize The Full Screen'/><author><name>Murray Speight</name><uri>http://www.blogger.com/profile/15535471089184667852</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
