<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Helion-Prime Solutions blog &#187; web-development</title>
	<atom:link href="http://blogs.helion-prime.com/category/web-development/feed" rel="self" type="application/rss+xml" />
	<link>http://blogs.helion-prime.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 10 May 2010 17:51:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>3 great ways to improve website usability</title>
		<link>http://blogs.helion-prime.com/2010/04/12/3-great-ways-to-improve-website-usability.html</link>
		<comments>http://blogs.helion-prime.com/2010/04/12/3-great-ways-to-improve-website-usability.html#comments</comments>
		<pubDate>Mon, 12 Apr 2010 12:10:39 +0000</pubDate>
		<dc:creator>vasiliy.kiryanov</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[web-development]]></category>

		<guid isPermaLink="false">http://blogs.helion-prime.com/?p=846</guid>
		<description><![CDATA[web heatmap systems
They have been used for displaying areas of a Web page most frequently scanned by visitors, and allow you to understand how people are using your website. This is quite useful to find layouts that don’t work as intended or areas that should be changed.

There are many open-source tools that you can integrate [...]]]></description>
			<content:encoded><![CDATA[<h2>web heatmap systems</h2>
<p>They have been used for displaying areas of a Web page most frequently scanned by visitors, and allow you to understand how people are using your website. This is quite useful to find layouts that don’t work as intended or areas that should be changed.</p>
<p><img src="http://blogs.helion-prime.com/wp-content/uploads/2010/04/heatmap_510.png" alt="heatmap screenshot" title="heatmap screenshot" width="506" height="268" class="alignnone size-full wp-image-850" /></p>
<p>There are many open-source tools that you can integrate into your site, free solutions and paid services with enormous amounts of features. Just make a Google search, and check few most appropriate solutions.</p>
<h2>user testing</h2>
<p><b>There are few steps: </b><br />
1. Understand what are your users, find out target group.<br />
2. Establish use cases of your system, main flows of your system like: site sing-up, password recovery, post search, etc.<br />
3. Ask some users from target group to go thru all use cases.</p>
<p><b>Few notes:</b><br />
Check where users stuck and simplify the flow.<br />
Ask simple questions, let them explain why they made something and if the result corresponded with the idea they had in mind.<br />
Ask them what functionality your site lack?<br />
Ask them what was hard to use on your site.</p>
<p>It can be hard to estimation how many users you may need for testing. Jeff Sauro wrote great article where explained why five users should be sufficient to find most of your interface problems.<br />
Check it: <a href="http://www.measuringusability.com/five-users.php">http://www.measuringusability.com/five-users.php</a></p>
<h2>log analysis/analytics</h2>
<p>You can get a lot of useful information that can make your site better by analyzing information from logs or by installing external tracking tools.</p>
<p>Features that can help to improve site usability:<br />
Visiting by days of week and rush hours,<br />
Domains/countries of hosts visitors,<br />
Most viewed posts and exit pages,<br />
Browsers used,<br />
HTTP errors,<br />
Screen size, etc.</p>
<h2>related links</h2>
<p>Scrolling and Attention : <a href="http://www.useit.com/alertbox/scrolling-attention.html">http://www.useit.com/alertbox/scrolling-attention.html</a><br />
Do users fail a task and still rate it as easy? : <a href="http://www.measuringusability.com/failed-sat.php">http://www.measuringusability.com/failed-sat.php</a></p>
<p>also I want to recommend 1 book that impressed me:<br />
<a href="http://www.amazon.com/gp/product/0321657292?ie=UTF8&#038;tag=usabil0b-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0321657292">Steve Krug’s &#8220;Rocket Surgery Made Easy: The Do-It-Yourself Guide to Finding and Fixing Usability Problems&#8221;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.helion-prime.com/2010/04/12/3-great-ways-to-improve-website-usability.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tools for easy user-interface(UI) prototyping</title>
		<link>http://blogs.helion-prime.com/2010/03/17/tools-for-easy-user-interfaceui-prototyping.html</link>
		<comments>http://blogs.helion-prime.com/2010/03/17/tools-for-easy-user-interfaceui-prototyping.html#comments</comments>
		<pubDate>Wed, 17 Mar 2010 16:22:06 +0000</pubDate>
		<dc:creator>vasiliy.kiryanov</dc:creator>
				<category><![CDATA[design]]></category>
		<category><![CDATA[web-development]]></category>

		<guid isPermaLink="false">http://blogs.helion-prime.com/?p=715</guid>
		<description><![CDATA[preamble
Every software development company needs special software to make prototypes of user-interface,
and it doesn’t mater if we do a new system or redesign of old one.
Often people say: they don’t need to prototype or they have special person for such tasks. Don’t believe them, it’s task of developers as well as writing tests.
If you still [...]]]></description>
			<content:encoded><![CDATA[<h2>preamble</h2>
<p>Every software development company needs special software to make prototypes of user-interface,<br />
and it doesn’t mater if we do a new system or redesign of old one.<br />
Often people say: they don’t need to prototype or they have special person for such tasks. Don’t believe them, it’s task of developers as well as writing tests.</p>
<p>If you still think differently about prototyping read famous book of Alan Kuper<br />
“The Inmates Are Running the Asylum” : <a href="http://www.amazon.com/Inmates-Are-Running-Asylum/dp/0672316498">http://www.amazon.com/Inmates-Are-Running-Asylum/dp/0672316498</a></p>
<h2>let&#8217;s do prototyping</h2>
<p>On Interaction Design Association (IxDA) [<a href="http://www.ixda.org/">http://www.ixda.org/</a>] discussion forum we can find that people use almost any tool to do prototyping: ACD Canvas, Microsoft Word, SmartDraw, Inspiration, Microsoft Power Point, etc.</p>
<p>First of all forget about software for graphic manipulations like: Adobe photoshop or Corell draw, then about software that don’t have any connection to prototyping at all. With such software you will lose your time, and will think that prototyping is hard work for designers.</p>
<p>There are big amount of commercial software to prototype user-interfaces.</p>
<p>As famous commercial software I can note:<br />
Axure: <a href="http://www.axure.com/">http://www.axure.com/</a><br />
Adobe inDesign: <a href="http://www.adobe.com/products/indesign/">http://www.adobe.com/products/indesign/</a><br />
Omnigraffle: <a href="http://www.omnigroup.com/products/omnigraffle/">http://www.omnigroup.com/products/omnigraffle/</a><br />
Pidoco: <a href="http://pidoco.com/en">http://pidoco.com/en</a></p>
<h2>great and free applications</h2>
<h3>Pencil</h3>
<p>site: <a href="http://www.evolus.vn/pencil/">http://www.evolus.vn/pencil/</a><br />
* Multi-page document with background page<br />
* Good text editing with rich-text supports<br />
* Exporting to HTML, PNG, Openoffice.org document, Word document and PDF.<br />
* Installing user-defined stencils and templates</p>
<p><img class="alignnone size-full wp-image-717" title="pencil editor" src="http://blogs.helion-prime.com/wp-content/uploads/2010/03/pencil.jpg" alt="pencil editor" width="475" height="313" /><br />
<br/></p>
<h3>Mockingbird</h3>
<p>site: <a href="http://gomockingbird.com/">http://gomockingbird.com/</a><br />
* Multi-page document<br />
* Good text editing<br />
* Exporting to PNG, and PDF.</p>
<p><img class="alignnone size-full wp-image-718" title="mockingbird editor" src="http://blogs.helion-prime.com/wp-content/uploads/2010/03/mockingbird.png" alt="mockingbird editor" width="475" height="329" /><br />
<br/></p>
<h3>Balsamiq Mockups</h3>
<p>site: <a href="http://www.balsamiq.com/products/mockups">http://www.balsamiq.com/products/mockups</a><br />
* No multi-page document, and background<br />
* Good text editing<br />
* Exporting only to PNG<br />
* Installing of user-defined elements only thru importing them as a pictures</p>
<p>additional feature: integration to popular project management tools</p>
<p><img class="alignnone size-full wp-image-719" title="balsamiq editor" src="http://blogs.helion-prime.com/wp-content/uploads/2010/03/balsamiq.png" alt="balsamiq editor" width="475" height="262" /><br />
<br/></p>
<h2>Still can&#8217;t select something</h2>
<p>As start point try Pencil: <a href="http://www.evolus.vn/pencil/">http://www.evolus.vn/pencil/</a><br />
It should meet all you basic expectations and save your money. </p>
<p>If you prefer to have commercial software that contain all features you ever wanted then try Axure:<br />
<a href="http://www.axure.com/">http://www.axure.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.helion-prime.com/2010/03/17/tools-for-easy-user-interfaceui-prototyping.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Log rotation in Ruby on Rails applications</title>
		<link>http://blogs.helion-prime.com/2009/11/19/log-rotation-in-ruby-on-rails-applications.html</link>
		<comments>http://blogs.helion-prime.com/2009/11/19/log-rotation-in-ruby-on-rails-applications.html#comments</comments>
		<pubDate>Thu, 19 Nov 2009 12:30:04 +0000</pubDate>
		<dc:creator>alex.shapovalov</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[web-development]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://blogs.helion-prime.com/?p=623</guid>
		<description><![CDATA[preamble
Even on mid-size applications logs grow enormously fast, it&#8217;s a pity Rails doesn&#8217;t provide built-in functionality for that like Apache web-server does. Fortunately there is an easy and fast solution for that issue.
1. Install cronolog
“cronolog [http://cronolog.org/] is a simple filter program that reads log file entries from standard input and writes each entry to the [...]]]></description>
			<content:encoded><![CDATA[<h2>preamble</h2>
<p>Even on mid-size applications logs grow enormously fast, it&#8217;s a pity Rails doesn&#8217;t provide built-in functionality for that like Apache web-server does. Fortunately there is an easy and fast solution for that issue.</p>
<h2>1. Install cronolog</h2>
<p>“cronolog [<a href="http://cronolog.org/">http://cronolog.org/</a>] is a simple filter program that reads log file entries from standard input and writes each entry to the output file specified by a filename template and the current date and time.”</p>
<p>For details, and list of parameters see: [<a href="http://cronolog.org/usage.html">http://cronolog.org/usage.html</a>]</p>
<p>On GNU/Linux Debian:</p>
<pre># apt-get install cronolog</pre>
<h2>2. Setup your Rails application</h2>
<p>Edit necessary environment file: like &#8216;config/environments/production.rb&#8217; file</p>
<div class="codecolorer-container ruby mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># system logger configuration</span><br />
<span style="color:#008000; font-style:italic;"># config.logger = SyslogLogger.new</span><br />
<br />
config.<span style="color:#9900CC;">logger</span> = <span style="color:#CC00FF; font-weight:bold;">Logger</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">IO</span>.<span style="color:#9900CC;">popen</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;FULL_PATH_TO_CRONOLOG log/production.log.%Y%m%d&quot;</span>, <span style="color:#996600;">&quot;w&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
config.<span style="color:#9900CC;">logger</span>.<span style="color:#9900CC;">level</span> = <span style="color:#CC00FF; font-weight:bold;">Logger</span>::INFO</div></td></tr></tbody></table></div>
<p>That&#8217;s all, fast and easy .. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.helion-prime.com/2009/11/19/log-rotation-in-ruby-on-rails-applications.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy image scaling for RoR developers</title>
		<link>http://blogs.helion-prime.com/2009/11/02/easy-image-scaling-for-ror-developers.html</link>
		<comments>http://blogs.helion-prime.com/2009/11/02/easy-image-scaling-for-ror-developers.html#comments</comments>
		<pubDate>Mon, 02 Nov 2009 16:21:40 +0000</pubDate>
		<dc:creator>alex.shapovalov</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[web-development]]></category>

		<guid isPermaLink="false">http://blogs.helion-prime.com/?p=588</guid>
		<description><![CDATA[We have common task: image scaling [http://en.wikipedia.org/wiki/Image_scaling], and correct understanding that: we can&#8217;t ask users to provide image of appropriate sizes, just use width and height CSS parameters for images, and thumbnail is always required feature.
Luckily we have ImageMagic library [http://www.imagemagick.org] and program interfaces for popular languages.
install RMagic gem
# gem install rmagick
add small code:
123456789101112131415161718192021222324252627282930require 'rubygems'
require [...]]]></description>
			<content:encoded><![CDATA[<p>We have common task: image scaling [<a href="http://en.wikipedia.org/wiki/Image_scaling">http://en.wikipedia.org/wiki/Image_scaling</a>], and correct understanding that: we can&#8217;t ask users to provide image of appropriate sizes, just use width and height CSS parameters for images, and thumbnail is always required feature.</p>
<p>Luckily we have ImageMagic library [<a href="http://www.imagemagick.org">http://www.imagemagick.org</a>] and program interfaces for popular languages.</p>
<p>install RMagic gem<br />
# gem install rmagick</p>
<p>add small code:</p>
<div class="codecolorer-container ruby mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'RMagick'</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">class</span> ImageController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController<br />
<br />
<span style="color:#9966CC; font-weight:bold;">def</span> index<br />
<br />
&nbsp; <span style="color:#008000; font-style:italic;"># determine basic params</span><br />
&nbsp; w = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:w</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; h = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:h</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; path = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:path</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> !w.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">empty</span>? <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> !h.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">empty</span>? <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; image = <span style="color:#6666ff; font-weight:bold;">Magick::Image</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">first</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; transformed_image = image.<span style="color:#9900CC;">resize_to_fill</span><span style="color:#006600; font-weight:bold;">&#40;</span>w.<span style="color:#9900CC;">to_i</span>, h.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># send image</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; send_data<span style="color:#006600; font-weight:bold;">&#40;</span>transformed_image.<span style="color:#9900CC;">to_blob</span>, <span style="color:#ff3333; font-weight:bold;">:disposition</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'inline'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:type</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;image/#{image.format.downcase}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> e<br />
&nbsp; &nbsp; &nbsp; &nbsp; Rails.<span style="color:#9900CC;">logger</span>.<span style="color:#9900CC;">error</span> e.<span style="color:#9900CC;">message</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Rails.<span style="color:#9900CC;">logger</span>.<span style="color:#9900CC;">error</span> e.<span style="color:#9900CC;">backtrace</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; render <span style="color:#ff3333; font-weight:bold;">:text</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Error processing image #{type}/#{aliaz}&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:code</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">404</span>, <span style="color:#ff3333; font-weight:bold;">:layout</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>Here to re-size images we use &#8216;resize_to_fill&#8217; ImageMagic method:<br />
re-size the image to fit within the specified dimensions while retaining the aspect ratio of the original image, and if necessary, crop the image in the larger dimension.</p>
<p>Sure you understand that resizing takes time and so you should cache re-sized images.</p>
<p>For additional info look thru:<br />
[<a href="http://studio.imagemagick.org/RMagick/doc/">http://studio.imagemagick.org/RMagick/doc/</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.helion-prime.com/2009/11/02/easy-image-scaling-for-ror-developers.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multi-domain applications in Ruby on Rails</title>
		<link>http://blogs.helion-prime.com/2009/09/03/multi-domain-applications-in-ruby-on-rails.html</link>
		<comments>http://blogs.helion-prime.com/2009/09/03/multi-domain-applications-in-ruby-on-rails.html#comments</comments>
		<pubDate>Thu, 03 Sep 2009 14:34:58 +0000</pubDate>
		<dc:creator>alex.shapovalov</dc:creator>
				<category><![CDATA[internet]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[web-development]]></category>

		<guid isPermaLink="false">http://blogs.helion-prime.com/?p=566</guid>
		<description><![CDATA[preamble
Ruby on Rails is a great framework that still luck some common features, among them: multi-domain support.
Here I will describe fast solution that doesn&#8217;t work for every browser and another one that do the work.
Ok, you did your homework and google something like &#8216;ruby on rails multi-domain&#8217;.
Very often provided solution:
edit environment.rb
1config.action_controller.session = &#123;:domain =&#62; '.mydomain.com'&#125;
With [...]]]></description>
			<content:encoded><![CDATA[<h2>preamble</h2>
<p>Ruby on Rails is a great framework that still luck some common features, among them: multi-domain support.<br />
Here I will describe fast solution that doesn&#8217;t work for every browser and another one that do the work.</p>
<p>Ok, you did your homework and google something like &#8216;ruby on rails multi-domain&#8217;.<br />
Very often provided solution:</p>
<p>edit environment.rb</p>
<div class="codecolorer-container ruby mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">session</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>:domain <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'.mydomain.com'</span><span style="color:#006600; font-weight:bold;">&#125;</span></div></td></tr></tbody></table></div>
<p>With that parameter Rails always read cookies from same domain. In real some browsers forbid for applications to read cookies from other domain due to insecurity of that operation. And as Mozilla Firefox in set of browsers that forbid that we just need another solution.</p>
<p>Now it&#8217;s clear that we should implement necessary functionality other way. </p>
<h2>Here we go:</h2>
<h3>1. will store session ID in the database(by default Rails2 store it in cookies)</h3>
<p>environment.rb:</p>
<div class="codecolorer-container ruby mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">session_store</span> = <span style="color:#ff3333; font-weight:bold;">:active_record_store</span></div></td></tr></tbody></table></div>
<p>and then execute rake task that create necessary DB migration:</p>
<div class="codecolorer-container ruby mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rake db:sessions:create</div></td></tr></tbody></table></div>
<p>Apply it with:  rake db:migrate.</p>
<h3>2. setup session parameters</h3>
<p>environment.rb:</p>
<div class="codecolorer-container ruby mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&quot;rubygems&quot;</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&quot;active_support&quot;</span><br />
<br />
config.<span style="color:#9900CC;">action_controller</span>.<span style="color:#9900CC;">session</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:session_key</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'_myapp_session_id'</span>, &nbsp; &nbsp;<span style="color:#008000; font-style:italic;"># session identification key</span><br />
&nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:secret</span> &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'89sHslddfsd98klasdKd'</span>, <span style="color:#008000; font-style:italic;"># hash code of session generator(make it random and longer)</span><br />
&nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:cookie_only</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>,<br />
&nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:expire_after</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">1</span>.<span style="color:#9900CC;">week</span>, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#008000; font-style:italic;"># TTL (time to live)</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div></td></tr></tbody></table></div>
<h3>3. let&#8217;s create session creation handler</h3>
<p>application_controller.rb:</p>
<div class="codecolorer-container ruby mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">before_filter <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>controller<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp;opts = controller.<span style="color:#9900CC;">request</span>.<span style="color:#9900CC;">session_options</span><br />
&nbsp; &nbsp;key = opts<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:key</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
<br />
&nbsp; &nbsp;<span style="color:#008000; font-style:italic;"># use session ID if it's passed</span><br />
&nbsp; &nbsp;<span style="color:#9966CC; font-weight:bold;">if</span> controller.<span style="color:#9900CC;">params</span><span style="color:#006600; font-weight:bold;">&#91;</span>key<span style="color:#006600; font-weight:bold;">&#93;</span>&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># session initialization with old ID</span><br />
&nbsp; &nbsp; &nbsp; controller.<span style="color:#9900CC;">session</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:nothing</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
<br />
&nbsp; &nbsp; &nbsp; opts<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span> = controller.<span style="color:#9900CC;">params</span><span style="color:#006600; font-weight:bold;">&#91;</span>key<span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; controller.<span style="color:#9900CC;">request</span>.<span style="color:#9900CC;">session_options</span> = opts<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># session initialization with new ID</span><br />
&nbsp; &nbsp; &nbsp; controller.<span style="color:#9900CC;">session</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:nothing</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp;<span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div></td></tr></tbody></table></div>
<h3>4. session pass</h3>
<p>We need to pass session ID as parameter when user change domain name, and within domain we still use cookie.</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">“#{request.session_options[:key]}” =&gt; request.session_options[:id]</div></td></tr></tbody></table></div>
<p>It&#8217;s wise to use session initialization before request.session_options[:id]  invocation due to Rails use lazy loading, and session can be uninitialized.<br />
Use something like: session[:nothing].</p>
<p>Pay attention that information that Rails get from cookie has bigger priority, and so if you have some parameter  in cookie Rails will use it firstly.</p>
<p><b>Note:</b><br />
An attacker can still steal you session ID by sniffing the network, or exploiting javascript, he/she gets the value from the cookie itself. If you care about security so much just use HTTPS.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.helion-prime.com/2009/09/03/multi-domain-applications-in-ruby-on-rails.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
