<?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-4139951739716161862</id><updated>2012-02-16T14:39:38.219-08:00</updated><title type='text'>Ruby Assist</title><subtitle type='html'>You want Ruby or Ruby On Rails ? We can do it! Hire us for Ruby, LAMP, AJAX .   


info {at} rubyassist {dot} com</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://rubyassist.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://rubyassist.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jagan Reddy</name><uri>http://www.blogger.com/profile/17987992266620378604</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>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4139951739716161862.post-5506959991218576113</id><published>2008-09-04T14:34:00.000-07:00</published><updated>2008-09-04T14:41:39.866-07:00</updated><title type='text'></title><content type='html'>&lt;span style="color:#660000;"&gt;Some information about session and caching in Rails!! &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#660000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;strong&gt;What is Session?&lt;/strong&gt;&lt;br /&gt;A session is a method of storing object data temporarily between different requests. A session makes it easy to work with logged-in users because you do not have to authenticate them each time they access a protected area of the application. Instead, you can authenticate them once and store their data in a session. A session is merely a container for storing a user’s current state in a web application. Unlike a cookie, session information is stored on the server instead of the client’s computer. Rails offer 4 different ways to store data in session.&lt;br /&gt;1. &lt;strong&gt;Memory Store&lt;/strong&gt;&lt;br /&gt;Rails keeps your session data in server memory&lt;br /&gt;2. &lt;strong&gt;ActiveRecord Store &lt;/strong&gt;&lt;br /&gt;Rails keeps session data in session table in the database&lt;br /&gt;3.  &lt;strong&gt;Drb Store&lt;/strong&gt;&lt;br /&gt;This store uses distributed Ruby to store a user’s session data. The performance is great, but it requires a bit more setup than the other stores.&lt;br /&gt;&lt;strong&gt;4. PStore&lt;br /&gt;&lt;/strong&gt;This is the default solution that is used in Rails. Using PStore, your session data is stored in small temporary files on your hard drive. These files are usually located in the tmp/sessions folder for the Rails app. The main downside of using the PStore is that you will have to do some session-pruning periodically because performance decreases as the number of sessions stored increases.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What is Caching?&lt;/strong&gt;&lt;br /&gt;Caching is the process of saving a copy of the results of a web request on the server or a local machine for subsequent requests&lt;br /&gt;Types:&lt;br /&gt;1. &lt;strong&gt;Page:&lt;/strong&gt;&lt;br /&gt;Whole static page is cached. Not suitable for dynamic pages like greeting messages, etc.&lt;br /&gt;2. &lt;strong&gt;Action:&lt;br /&gt;&lt;/strong&gt;This is useful for authenticated users. It helps to keep the dynamic content on the sidebar.&lt;br /&gt;3. &lt;strong&gt;Fragment:&lt;/strong&gt;&lt;br /&gt;You need to cache the portion of a page like header and footer.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Four places to keep the cache:&lt;br /&gt;1. MemoryStore:&lt;/strong&gt; This store keeps the fragments in your application's memory, which can potentially take up a lot of memory on your server. It is used by default, but it is hard to manage and scale if your application becomes popular.&lt;br /&gt;&lt;strong&gt;2. FileStore:&lt;/strong&gt; This store keeps the fragments on the hard disk instead of in memory. It works well if you have a lot of file storage and have outgrown the MemoryStore.&lt;br /&gt;&lt;strong&gt;3. DRbStore&lt;/strong&gt;: This store keeps the fragments in the memory on a separate shared Drb server (Drb stands for Distributed Ruby). It keeps only one cache around for all processes. This is a complex solution because it involves setting up a secondary server.&lt;br /&gt;&lt;strong&gt;4. MemCacheStore:&lt;/strong&gt; Similar to DRbStore in that it stores your caches on a separate server, but uses the MemCache library. It also requires you to install the ruby-memcache library.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4139951739716161862-5506959991218576113?l=rubyassist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rubyassist.blogspot.com/feeds/5506959991218576113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4139951739716161862&amp;postID=5506959991218576113' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/5506959991218576113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/5506959991218576113'/><link rel='alternate' type='text/html' href='http://rubyassist.blogspot.com/2008/09/some-information-about-session-and.html' title=''/><author><name>Rup</name><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-4139951739716161862.post-3255246615311863623</id><published>2008-08-20T15:56:00.001-07:00</published><updated>2008-08-20T15:56:37.918-07:00</updated><title type='text'>configuring Capistrano #1</title><content type='html'>&lt;h3&gt;Details&lt;/h3&gt;  &lt;p&gt;In this article, I have taken quite a bit of space to try and explain what each setting is, and what it does.&lt;/p&gt;  &lt;p&gt;As such, don't be put off by the apparent length of the article as, by the end of it, you will understand and have a good grasp of what is happening when you use Capistrano.&lt;/p&gt;  &lt;h3&gt;deploy.rb&lt;/h3&gt;  &lt;p&gt;If you are not in the rails application folder, then move there now (remember this is on your local workstation and not on your Slice):&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;cd ~/dev/project1&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;The location may vary depending where on your workstation you have placed the rails application. &lt;/p&gt;  &lt;p&gt;Let's get straight on and open up the Capistrano deploy file:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;nano config/deploy.rb&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;The default file looks like this:&lt;/p&gt;  &lt;pre&gt;&lt;code class="ruby"&gt;set &lt;span class="symbol"&gt;:application&lt;/span&gt;, &lt;span class="string"&gt;"set your application name here"&lt;/span&gt;&lt;br /&gt;set &lt;span class="symbol"&gt;:repository&lt;/span&gt;,  &lt;span class="string"&gt;"set your repository location here"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="comment"&gt;# If you aren't deploying to /u/apps/#{application} on the target&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# servers (which is the default), you can specify the actual location&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# via the :deploy_to variable:&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# set :deploy_to, "/var/www/#{application}"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="comment"&gt;# If you aren't using Subversion to manage your source code, specify&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# your SCM below:&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# set :scm, :subversion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;role &lt;span class="symbol"&gt;:app&lt;/span&gt;, &lt;span class="string"&gt;"your app-server here"&lt;/span&gt;&lt;br /&gt;role &lt;span class="symbol"&gt;:web&lt;/span&gt;, &lt;span class="string"&gt;"your web-server here"&lt;/span&gt;&lt;br /&gt;role &lt;span class="symbol"&gt;:db&lt;/span&gt;,  &lt;span class="string"&gt;"your db-server here"&lt;/span&gt;, &lt;span class="symbol"&gt;:primary&lt;/span&gt; =&gt; &lt;span class="constants"&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Fairly simple and, apart from a few additions, is sufficient to get started.&lt;/p&gt;  &lt;h3&gt;Application, user and repository&lt;/h3&gt;  &lt;p&gt;Seem logical to start at the top of the file and work our way down so the first thing is the application name.&lt;/p&gt;  &lt;p&gt;This can be anything you like. However, it makes a lot of sense to use the domain name as the application name.&lt;/p&gt;  &lt;p&gt;This means that the 'application' variable can be used further on in the file and it keeps in line with the protocols we are already using when naming vhost files, etc.&lt;/p&gt;  &lt;p&gt;So, set the application name as follows:&lt;/p&gt;  &lt;pre&gt;&lt;code class="ruby"&gt;set &lt;span class="symbol"&gt;:application&lt;/span&gt;, &lt;span class="string"&gt;"domain.com"&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Next we will add a variable for a username. It's important you set a user here as permission issues often arise from using your local workstation username instead of the Slice username.&lt;/p&gt;  &lt;p&gt;Add this line straight after the application variable:&lt;/p&gt;  &lt;pre&gt;&lt;code class="ruby"&gt;set &lt;span class="symbol"&gt;:user&lt;/span&gt;, &lt;span class="string"&gt;"demo"&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;For the repository, enter the same details that you used to check out project1:&lt;/p&gt;  &lt;pre&gt;&lt;code class="ruby"&gt;set &lt;span class="symbol"&gt;:repository&lt;/span&gt;,  &lt;span class="string"&gt;"svn+project1ssh://123.45.67.890/home/demo/repository/project1"&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;h3&gt;SSH port&lt;/h3&gt;  &lt;p&gt;One essential setting that is not mentioned is how to define the SSH port.&lt;/p&gt;  &lt;p&gt;When Capistrano connects to your Slice via SSH it will use port 22 (the default SSH port). However, when we setup the Slice, we defined the SSH port to be 30000.&lt;/p&gt;  &lt;p&gt;Capistrano needs to know about this.&lt;/p&gt;  &lt;p&gt;Setting the port is as simple as:&lt;/p&gt;  &lt;pre&gt;&lt;code class="ruby"&gt;set &lt;span class="symbol"&gt;:port&lt;/span&gt;, 30000&lt;/code&gt;&lt;/pre&gt;  &lt;h3&gt;Deployment path&lt;/h3&gt;  &lt;p&gt;Now the SSH port has been set, we can set the deployment path.&lt;/p&gt;  &lt;p&gt;When we setup the Slice and Nginx vhosts, we used the public_html folder in our home directory.&lt;/p&gt;  &lt;p&gt;We've already set the application name (see above) so we can use that variable again.&lt;/p&gt;  &lt;p&gt;So the next line to add is this:&lt;/p&gt;  &lt;pre&gt;&lt;code class="ruby"&gt;set &lt;span class="symbol"&gt;:deploy_to&lt;/span&gt;, &lt;span class="string"&gt;"/home/demo/public_html/#{application}"&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Note the use of the 'application' variable at the end of the entry. If we changed the 'set :application' name, that change would be reflected in this setting.&lt;/p&gt;  &lt;h3&gt;App, web and db&lt;/h3&gt;  &lt;p&gt;The final 3 settings (at this stage) are shown as 'app', 'web' and 'db'.&lt;/p&gt;  &lt;p&gt;The vast majority of users will have all 3 variables pointing to the same place so it can seem a little confusing to have 3 settings here as if they are different things.&lt;/p&gt;  &lt;p&gt;However, do remember that you can have your database (db) on another Slice and so on. These settings are then very useful as it tells Capistrano where the db is, where the app is and so on.&lt;/p&gt;  &lt;p&gt;As an aside, we can define a new variable here and call it 'location'. We can then assign a URI to that variable and use it in all 3 settings.&lt;/p&gt;  &lt;p&gt;So this section could look something like this:&lt;/p&gt;  &lt;pre&gt;&lt;code class="ruby"&gt;set &lt;span class="symbol"&gt;:location&lt;/span&gt;, &lt;span class="string"&gt;"domain2.com"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;role &lt;span class="symbol"&gt;:app&lt;/span&gt;, location&lt;br /&gt;role &lt;span class="symbol"&gt;:web&lt;/span&gt;, location&lt;br /&gt;role &lt;span class="symbol"&gt;:db&lt;/span&gt;,  location, &lt;span class="symbol"&gt;:primary&lt;/span&gt; =&gt; &lt;span class="constants"&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;That is one way of doing it and I mention it as an option for you to play with.&lt;/p&gt;  &lt;p&gt;For this example though, I am simply going to use the 'application' variable as everything is happening on the single Slice.&lt;/p&gt;  &lt;p&gt;As such, the 3 settings will look like this:&lt;/p&gt;  &lt;pre&gt;&lt;code class="ruby"&gt;role &lt;span class="symbol"&gt;:app&lt;/span&gt;, application&lt;br /&gt;role &lt;span class="symbol"&gt;:web&lt;/span&gt;, application&lt;br /&gt;role &lt;span class="symbol"&gt;:db&lt;/span&gt;, application , &lt;span class="symbol"&gt;:primary&lt;/span&gt; =&gt; &lt;span class="constants"&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;h3&gt;Completed file&lt;/h3&gt;  &lt;p&gt;So this is what the completed deploy.rb will look like:&lt;/p&gt;  &lt;pre&gt;&lt;code class="ruby"&gt;set &lt;span class="symbol"&gt;:application&lt;/span&gt;, &lt;span class="string"&gt;"domain.com"&lt;/span&gt;&lt;br /&gt;set &lt;span class="symbol"&gt;:user&lt;/span&gt;, &lt;span class="string"&gt;"demo"&lt;/span&gt;&lt;br /&gt;set &lt;span class="symbol"&gt;:repository&lt;/span&gt;,  &lt;span class="string"&gt;"svn+project1ssh://123.45.67.890/home/demo/repository/project1"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="comment"&gt;# If you aren't deploying to /u/apps/#{application} on the target&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# servers (which is the default), you can specify the actual location&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# via the :deploy_to variable:&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# set :deploy_to, "/var/www/#{application}"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;set &lt;span class="symbol"&gt;:port&lt;/span&gt;, 30000&lt;br /&gt;&lt;br /&gt;set &lt;span class="symbol"&gt;:deploy_to&lt;/span&gt;, &lt;span class="string"&gt;"/home/demo/public_html/#{application}"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="comment"&gt;# If you aren't using Subversion to manage your source code, specify&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# your SCM below:&lt;/span&gt;&lt;br /&gt;&lt;span class="comment"&gt;# set :scm, :subversion&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;role &lt;span class="symbol"&gt;:app&lt;/span&gt;, application&lt;br /&gt;role &lt;span class="symbol"&gt;:web&lt;/span&gt;, application&lt;br /&gt;role &lt;span class="symbol"&gt;:db&lt;/span&gt;, application , &lt;span class="symbol"&gt;:primary&lt;/span&gt; =&gt; &lt;span class="constants"&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Still pretty basic as this stage (there is lot more we can do later on) but it is enough to enter our first Capistrano command...&lt;/p&gt;  &lt;h3&gt;public_html&lt;/h3&gt;  &lt;p&gt;Before we enter the first command, let's log into our Slice and move into the public_html folder:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;ssh -p 30000 demo@123.45.67.890&lt;br /&gt;&lt;br /&gt;cd /home/demo/public_html&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Unless you already have a working Slice, the directory is going to be empty:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;ls&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;That produces no output as the folder is empty.&lt;/p&gt;  &lt;p&gt;Well, let's enter our first Capistrano command and then have another look.&lt;/p&gt;  &lt;h3&gt;deploy:setup&lt;/h3&gt;  &lt;p&gt;Back on our local workstation (&lt;em&gt;not&lt;/em&gt; the Slice!) we can now enter:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;cap deploy:setup&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Pretty minimal stuff.&lt;/p&gt;  &lt;p&gt;However, exciting things are taking place and this really shows not only the power, but the ease of using something like Capistrano.&lt;/p&gt;  &lt;p&gt;So what happened?&lt;/p&gt;  &lt;p&gt;Well, let's take another look at the public_html folder on the Slice:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;ls&lt;br /&gt;...&lt;br /&gt;domain.com&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;That's new.&lt;/p&gt;  &lt;h3&gt;Directory Structure&lt;/h3&gt;  &lt;p&gt;What Capistrano has done is really quite clever.&lt;/p&gt;  &lt;p&gt;It's logged into the Slice and, using the settings from the deploy.rb file, has created a directory structure that will be used for future deployments.&lt;/p&gt;  &lt;p&gt;Inside the parent folder are two folders called 'releases' and 'shared'.&lt;/p&gt;  &lt;p&gt;Inside the 'shared' folder are permanent folders for the logs, pids and system info.&lt;/p&gt;  &lt;p&gt;So from one command, Capistrano is now ready to deploy the application.&lt;/p&gt;  &lt;p&gt;Nice.&lt;/p&gt;  &lt;h3&gt;Summary&lt;/h3&gt;  &lt;p&gt;We've configured the deploy.rb file that Capistrano uses to setup and deploy our application.&lt;/p&gt;  &lt;p&gt;Then, using a single command, we created the directory structure that will be used for future deployments.&lt;/p&gt;  &lt;p&gt;A lot has happened, but now that we are more familiar with the deploy.rb file, we can move on to &lt;a href="http://articles.slicehost.com/2008/1/22/capistrano-series-configuring-capistrano-2" title="&amp;quot;Configuring Capistrano #2"&gt;deploying the application&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4139951739716161862-3255246615311863623?l=rubyassist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rubyassist.blogspot.com/feeds/3255246615311863623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4139951739716161862&amp;postID=3255246615311863623' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/3255246615311863623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/3255246615311863623'/><link rel='alternate' type='text/html' href='http://rubyassist.blogspot.com/2008/08/configuring-capistrano-1.html' title='configuring Capistrano #1'/><author><name>Jagan Reddy</name><uri>http://www.blogger.com/profile/17987992266620378604</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-4139951739716161862.post-1642351837866275059</id><published>2008-08-20T15:53:00.000-07:00</published><updated>2008-08-20T15:54:15.130-07:00</updated><title type='text'>Apache vhosts, rails and mongrels</title><content type='html'>&lt;p&gt;There are several ways of serving a Ruby on Rails application, one of which is to use Apache to proxy requests to mongrels.&lt;/p&gt;  &lt;p&gt;There are a few ways of completing this and we're going to look at one simple solution. Other ways will be looked at in future articles.&lt;/p&gt;        &lt;hr /&gt;                          &lt;h3&gt;Setup&lt;/h3&gt;  &lt;p&gt;Just a quick note on where we are in the setup. I have my base Ubuntu Feisty installed which I updated and secured. I then installed MySQL and Ruby on Rails as per &lt;a href="http://articles.slicehost.com/2007/9/11/ubuntu-feisty-mysql-and-ror" title="Ubuntu Feisty MySQL and Ruby on Rails"&gt;this article&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Once the basics were done I then proceed to &lt;a href="http://articles.slicehost.com/2007/9/24/ubuntu-feisty-installing-apache-and-php5" title="Ubuntu Feisty Apache and PHP install"&gt;install Apache and PHP&lt;/a&gt;. Of course, you can leave out the PHP part.&lt;/p&gt;  &lt;p&gt;I then created a public_html folder in my home partition and created the correct permissions as &lt;a href="http://articles.slicehost.com/2007/9/18/apache-virtual-hosts-permissions" title="Apache Virtual Host Permissions"&gt;shown here&lt;/a&gt;.&lt;/p&gt;  &lt;h3&gt;Rails Application&lt;/h3&gt;  &lt;p&gt;You can use a pre-existing Rails application or, like me, create a new one from scratch. To create a new one, move into your public_html folder:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;cd /home/demo/public_html&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;and create a new Ruby on Rails application:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;rails railsapp&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;move into the directory:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;cd railsapp&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;You will notice that the created folders are very similar to the default vhosts layout I describe &lt;a href="http://articles.slicehost.com/2007/9/13/multiple-hosts-layout" title="Multiple Hosts Layout"&gt;here&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As such, we don't need to create any extra folders as the Apache logs can go into /log and so on.&lt;/p&gt;  &lt;h3&gt;Mongrels&lt;/h3&gt;  &lt;p&gt;Let's install the mongrels via ruby gems:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;sudo gem install mongrel --include-dependencies&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Once done we can move onto the Apache configuration.&lt;/p&gt;  &lt;h3&gt;Apache modules&lt;/h3&gt;  &lt;p&gt;Apache will need certain modules to be enabled to allow it to pass the requests to the mongrels.&lt;/p&gt;  &lt;p&gt;There are four specific modules that we need. Enable them like so:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;sudo a2enmod proxy&lt;br /&gt;sudo a2enmod proxy_balancer&lt;br /&gt;sudo a2enmod proxy_http&lt;br /&gt;sudo a2enmod rewrite&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;As suggested by the module commands, reload Apache:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;sudo /etc/init.d/apache2 force-reload&lt;/code&gt;&lt;/pre&gt;  &lt;h3&gt;Virtual host&lt;/h3&gt;  &lt;p&gt;Now we need to create a new virtual host for the 'railsapp' we created earlier:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;sudo nano /etc/apache2/sites-available/domain.com&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Obviously use your domain name instead of my example of domain.com&lt;/p&gt;  &lt;p&gt;At this stage we are only doing a basic configuration so you can enter the following in the vhosts file:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;&lt;virtualhost&gt;&lt;br /&gt; ServerName domain.com&lt;br /&gt; ServerAlias www.domain.com&lt;br /&gt;&lt;br /&gt; DocumentRoot /home/demo/public_html/railsapp/public&lt;br /&gt;&lt;br /&gt; RewriteEngine On&lt;br /&gt;&lt;br /&gt; &lt;proxy&gt;&lt;br /&gt;   BalancerMember http://127.0.0.1:8000&lt;br /&gt;   BalancerMember http://127.0.0.1:8001&lt;br /&gt; &lt;/proxy&gt;&lt;br /&gt;&lt;br /&gt; # Redirect all non-static requests to Mongrel&lt;br /&gt; RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f&lt;br /&gt; RewriteRule ^/(.*)$ balancer://mongrelcluster%{REQUEST_URI} [P,QSA,L]&lt;br /&gt;&lt;br /&gt; ProxyPass / balancer://mongrelcluster/&lt;br /&gt; ProxyPassReverse / balancer://mongrelcluster/&lt;br /&gt; ProxyPreserveHost on&lt;br /&gt;&lt;br /&gt; &lt;proxy&gt;&lt;br /&gt;   Order deny,allow&lt;br /&gt;   Allow from all&lt;br /&gt; &lt;/proxy&gt;&lt;br /&gt;&lt;br /&gt; # Custom log file locations&lt;br /&gt; ErrorLog  /home/demo/public_html/railsapp/log/error.log&lt;br /&gt; CustomLog /home/demo/public_html/railsapp/log/access.log combined&lt;br /&gt;&lt;br /&gt;&lt;/virtualhost&gt;&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Take each section at a time and you will see that the basics are exactly the same as for a 'normal' vhost configuration.&lt;/p&gt;  &lt;p&gt;We have the ServerName, DocumentRoot and Log locations.&lt;/p&gt;  &lt;p&gt;Where it differs is the addition of the Proxy settings.&lt;/p&gt;  &lt;p&gt;In this example, we will use 2 mongrels running on ports 8000 and 8001 in a balancer named 'mongrelcluster' (call it something more expressive if you have several rails sites - it is also not technically a mongrel cluster but, hey, it's a good name).&lt;/p&gt;  &lt;p&gt;The next sections tell Apache to pass the proxy request to the defined balancer. It then sets the permissions on the Proxy so we don't have a dreaded permissions error.&lt;/p&gt;  &lt;p&gt;Do note the trailing slash (/) is very important in the ProxyPass settings. Miss them out and it won't work.&lt;/p&gt;  &lt;h3&gt;Enable&lt;/h3&gt;  &lt;p&gt;After all of this, don't forget to enable the new vhost:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;sudo a2ensite domain.com&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;And as requested:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;sudo /etc/init.d/apache2 reload&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;If you have a warning regarding mixed ports, you will need to ensure the default vhost has been changed to reflect specific port access as follows:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;NameVirtualHost *:80&lt;br /&gt;&lt;virtualhost&gt;&lt;br /&gt;...&lt;br /&gt;...&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;Reload Apache and the warning will have gone.&lt;/p&gt;  &lt;h3&gt;Start your engines&lt;/h3&gt;  &lt;p&gt;All that's left is to start the two mongrel processes on the ports defined in the vhost. If you are not already in your railsapp directory, move there now:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;cd /home/demo/public_html/railsapp&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;We will start two separate mongrels:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;mongrel_rails start -d -e production -p 8000 -P log/mongrel8000.pid&lt;br /&gt;mongrel_rails start -d -e production -p 8001 -P log/mongrel8001.pid&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;As Feisty uses ruby -v1.8.5 as the default you will received a warning:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;** Ruby version is not up-to-date; loading cgi_multipart_eof_fix&lt;/code&gt;&lt;/pre&gt;  &lt;p&gt;It is just a warning and, until the aptitude version is updated or you install from source, nothing to be concerned about.&lt;/p&gt;  &lt;h3&gt;Navigate&lt;/h3&gt;  &lt;p&gt;Once done, navigate to your domain:&lt;/p&gt;  &lt;pre&gt;&lt;code&gt;http://www.domain.com&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4139951739716161862-1642351837866275059?l=rubyassist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rubyassist.blogspot.com/feeds/1642351837866275059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4139951739716161862&amp;postID=1642351837866275059' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/1642351837866275059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/1642351837866275059'/><link rel='alternate' type='text/html' href='http://rubyassist.blogspot.com/2008/08/apache-vhosts-rails-and-mongrels.html' title='Apache vhosts, rails and mongrels'/><author><name>Jagan Reddy</name><uri>http://www.blogger.com/profile/17987992266620378604</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-4139951739716161862.post-158954274950989791</id><published>2008-08-19T10:33:00.001-07:00</published><updated>2008-09-04T14:45:39.980-07:00</updated><title type='text'>Dojo Button and Rails Helpers</title><content type='html'>When i tried to use dojo buttons on rails partials , i felt happy about dojo widgets.&lt;br /&gt;&lt;br /&gt;But if i have to use save_tag button or i want to include button in link_to_remote function,&lt;br /&gt;I dont have option to get dojo style button.&lt;br /&gt;&lt;br /&gt;I have used firebug to get the required dojo classes for dojo button and created following helper methods.&lt;br /&gt;&lt;br /&gt;def dojo_button(name)&lt;br /&gt;'+name.to_s&lt;br /&gt;end&lt;br /&gt;def dojo_button_class&lt;br /&gt;"dijit dijitLeft dijitInline dijitStretch dijitButtonNode dijitButtonContents dijitButton"&lt;br /&gt; end&lt;br /&gt;Remember u need to use dojo.parser.parse() method of making ajax call using partials.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4139951739716161862-158954274950989791?l=rubyassist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rubyassist.blogspot.com/feeds/158954274950989791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4139951739716161862&amp;postID=158954274950989791' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/158954274950989791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/158954274950989791'/><link rel='alternate' type='text/html' href='http://rubyassist.blogspot.com/2008/08/dojo-button-and-rails-helpers.html' title='Dojo Button and Rails Helpers'/><author><name>Jagan Reddy</name><uri>http://www.blogger.com/profile/17987992266620378604</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-4139951739716161862.post-7805837537651386603</id><published>2008-08-19T10:16:00.001-07:00</published><updated>2008-08-19T10:16:42.779-07:00</updated><title type='text'>Ruby: Floating point round off</title><content type='html'>my method of doing this as&lt;br /&gt;&lt;br /&gt; def round(float, decimal_places)  # By Jagan  Reddy&lt;br /&gt;   exponent = decimal_places + 2&lt;br /&gt;   @float = float*(10**exponent)&lt;br /&gt;   @float = @float.round&lt;br /&gt;   @float = @float / (10.0**exponent)&lt;br /&gt; end&lt;br /&gt;&lt;br /&gt;In short we can also do this way&lt;br /&gt;&lt;pre&gt;class Float&lt;br /&gt;def round_to(i)&lt;br /&gt;  (self * 10**i).round.to_f / 10**i&lt;br /&gt; end&lt;br /&gt;end&lt;br /&gt;value = 1328.3337&lt;br /&gt;value.round_to(3)&lt;br /&gt;=&gt;1328.334&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4139951739716161862-7805837537651386603?l=rubyassist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rubyassist.blogspot.com/feeds/7805837537651386603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4139951739716161862&amp;postID=7805837537651386603' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/7805837537651386603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/7805837537651386603'/><link rel='alternate' type='text/html' href='http://rubyassist.blogspot.com/2008/08/ruby-floating-point-round-off.html' title='Ruby: Floating point round off'/><author><name>Jagan Reddy</name><uri>http://www.blogger.com/profile/17987992266620378604</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-4139951739716161862.post-4293052681839830114</id><published>2008-08-19T10:15:00.000-07:00</published><updated>2008-08-19T10:16:17.439-07:00</updated><title type='text'>save_tag to avoid multiple click in IE and Firefox</title><content type='html'>##############################################################################&lt;br /&gt;  # Overrides sumit_tag for disable save after click event  --JAGAN REDDY&lt;br /&gt;  ##############################################################################&lt;br /&gt;  def commit_tag(value,options={})&lt;br /&gt;    options.stringify_keys!&lt;br /&gt;    submit_tag value, options.merge(:onclick =&gt; '&lt;br /&gt;   &lt;br /&gt;     if(window.addEventListener)&lt;br /&gt;     {&lt;br /&gt;       this.disabled = true;&lt;br /&gt;     }&lt;br /&gt;     else&lt;br /&gt;     { // IE&lt;br /&gt;      // this.disabled = true;&lt;br /&gt;     setTimeout(m(), 10000);&lt;br /&gt;     }&lt;br /&gt;     function m()&lt;br /&gt;     {&lt;br /&gt;      // var  tag = window.event.srcElement.tagName&lt;br /&gt;       this.disabled = true;&lt;br /&gt;     }')&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;use this in apllication_helper.rb&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4139951739716161862-4293052681839830114?l=rubyassist.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rubyassist.blogspot.com/feeds/4293052681839830114/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4139951739716161862&amp;postID=4293052681839830114' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/4293052681839830114'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4139951739716161862/posts/default/4293052681839830114'/><link rel='alternate' type='text/html' href='http://rubyassist.blogspot.com/2008/08/savetag-to-avoid-multiple-click-in-ie.html' title='save_tag to avoid multiple click in IE and Firefox'/><author><name>Jagan Reddy</name><uri>http://www.blogger.com/profile/17987992266620378604</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>
