Contents
Sinatra
Installation
-
Open Web Platform Installer and install "Ruby project":
- Open project's home page and follow steps in "Sinatra" section:
- Create config.ru file with the following content:
#config.ru require './app' run Sinatra::Application
- Create app.rb file with the following content:
#app.rb require 'sinatra' get '/' do "Hello World!" end
Output of example Sinatra application:
Deployment
To deploy Ruby on Rails application you will need to install Ruby Hosting Package on a target server. Then just copy IIS web site from one machine to another.
web.config example
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<heliconZoo>
<application name="ruby.project" >
<environmentVariables>
<add name="RAILS_RELATIVE_URL_ROOT" value="%APPL_VIRTUAL_PATH%" />
<!--
Deploy file includes the most common commands required to prepare application before launch (bundle install,
migrations etc.)
It is also possible to specify here any script which evenually will be run by rubyw.exe.
-->
<add name="DEPLOY_FILE" value="deploy.rb" />
<!-- By default we run Rails in production mode -->
<add name="RACK_ENV" value="production" />
<!-- Web console location -->
<!-- security rules for console are placed in /console/web.config -->
<add name="CONSOLE_URL" value="console" />
</environmentVariables>
</application>
</heliconZoo>
<handlers>
<!-- Ruby 1.9 over FastCGI -->
<add name="ruby.project#x86" scriptProcessor="ruby.1.9.rack" path="*" verb="*"
modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified"
requireAccess="Script" />
<add name="ruby.project#x64" scriptProcessor="ruby.1.9.rack" path="*" verb="*"
modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified"
requireAccess="Script" />
</handlers>
<!-- URL Rewrite rules to pass static files, limit console access, etc. -->
<rewrite>
<rules>
<!-- This rule rewrites '/' requests to /public/index.html -->
<rule name="index" stopProcessing="true">
<match url="^$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{APPL_PHYSICAL_PATH}" pattern="(.*)" ignoreCase="false" />
<add input="{C:1}public\index.html" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="public/index.html" />
</rule>
<!-- Rewrite static files requests to /public folder to bypass Ruby processing.
This speeds up static files significantly. Please put all your static
files into the /public folder. -->
<rule name="Static Files" stopProcessing="true">
<match url="^(?!public)(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{APPL_PHYSICAL_PATH}" pattern="(.*)" ignoreCase="false" />
<add input="{C:1}public\{R:1}" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="public/{R:1}" />
</rule>
<!-- This rule rewrites Rails assets requests. Copy web.config file from
/public folder to /app/assets to speed it up. -->
<rule name="Rails 3.1 assets" stopProcessing="true">
<match url="^assets/(.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{APPL_PHYSICAL_PATH}" pattern="(.*)" ignoreCase="false" />
<add input="{C:1}app\assets\{R:1}" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="app/assets/{R:1}" />
</rule>
<!-- This rule shows welcome page when no Rack application exist. -->
<rule name="Rewrite to Zoo index if that's an empty application" stopProcessing="true">
<match url="^/?$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{APPL_PHYSICAL_PATH}" pattern="(.*)" ignoreCase="false" />
<add input="{C:1}config.ru" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="public/zoo-index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Environment variables:
-
APP_WORKER
— path to the main application script. Note, Helicon Zoo automatically detects Rails and picks up “config.ru” file. -
DEPLOY_FILE
— optional path to a ruby script which is run before application launch and every time IIS application pool recycles. The script usually contains deployment instructions to satisfy application dependencies and database migrations. -
DEPLOY_LOG
— optional path to a text file containing the output of the deploy script. It’s recommended to set this variable if you use deploy script. -
RACK_ENV
— specifies application running mode. Default value is “production”. This variable is duplicated intoRAILS_ENV
variable.