Rails Quickstart
From Apis Networks Wiki
Preface
The quickstart guide uses an example application name of myapp, which will be installed under /var/www/. Further, the application will be accessed via http://rails.mydomain.com/. rails is a subdomain created via Add Subdomain assigned to /var/www/rails/public. Comments which should be omitted from the terminal are prefixed at the beginning of the line with #.
Guide
1. Login to apnscp and visit Development > Code Frameworks to install Ruby on Rails. The latest gems from RubyForge will be installed. You may revisit Code Frameworks at a later date to upgrade Ruby/RubyGems and Development > Package Manager for gems.
2. Login to the SSH. If using the ssh binary, then the command ssh user@domain is not correct; use ssh -l user@domain domain.
3. Deploy a Rails application from the shell.
Note: it is important that if the Rails application resides in the same directory as the document root, that you do not use the same name as the directory of the document root. For example, naming an application html in /var/www/html/ would cause a problem.
cd /var/www/
rails myapp
cd myapp/
nano public/.htaccess
4. You will be in nano, a text editor. Masochists may replace nano with ed. Add the following lines, substituting <HTTP BASE> with the HTTP base path from Account > Account Summary.
RailsBaseUri /
PassengerAppRoot <HTTP BASE>/var/www/myapp
5. Associate a subdomain with myapp/public via Web > Subdomains. In this example, the web site folder is /var/www/myapp/public and subdomain may be anything.
6. Load the sqlite3 gem for database connectivity. Open environment.rb within a text editor:
cd /var/www/myapp/environment
nano environment.rb
Navigate to the Rails::Initializer code block and load the gem via config.gem:
Rails::Initializer.run do |config|
# Settings in config/environments/* take ...
# Comments ...
config.gem "sqlite3"
# more comments ...
end
7. Access http://rails.mydomain.com/. You should see the Rails placeholder page. Now it is time to setup your routes and write some efficient, portable, non-crashing code.

