
Knowledge Base - FAQ
You can lock your app into the older versions of the Rails gems by changing your config/environment.rb to read:
# Set use_latest=true for latest gem install # otherwise use 0.13.1 version of Rails use_latest = false if use_latest gem 'active_support' gem 'active_record' gem 'action_controller' gem 'action_mailer' gem 'action_web_service' else gem 'activesupport', '= 1.1.1' gem 'actionwebservice', '= 0.8.1' gem 'activerecord', '= 1.11.1' gem 'actionpack', '= 1.9.1' gem 'actionmailer', '= 1.0.1' gem 'rails', '= 0.13.1' end require 'active_support' require 'active_record' require 'action_controller' require 'action_mailer' require 'action_web_service'
Kattare supports a ruby environment manager called the Ruby Version Manager, or RVM for short. It is a powerful way of being able to run any supported version of ruby you want from within your Kattare account.
A quick warning: Each version of Ruby you install is going to eat into your storage quota. In my experience, a full version of Ruby + Rails came out to be around 250 MB.
From the command line, run:
'rvm help' to get a list of help topics.'rvm list known' to get a list of supported ruby versions.
'rvm install <version>' to install a copy of ruby into your account.
Typical installation of a new version will take 10-15 minutes. It does a custom download, compile, and install of everything you need.
For more installation information (eg, how to specify various patch versions, or subversion versions:
http://rvm.beginrescueend.com/rubies/installing/
'rvm use <version>' to use the version you just installed.
'gem install rails' to install rails into your new ruby
'gem install fcgi' to install fastcgi support (required by Kattare)
Important! After each installed gem you need to re-run 'rvm use <version>' to get it to pick up your new gems.
Important! If using rails >= 2.3.3 the fcgi dispatchers are not included unless you specify --with-dispatchers to your rails command.
'rvm --default <version>' to make the version you just installed the default for your account.
For more regarding setting the default version, see:
http://rvm.beginrescueend.com/rubies/default/
'rvm list' to get a list of your installed ruby versions.
'rvm help' for all kinds of handy rvm information.
And when you're all done setting up your environment, here's our howto for Setting up Ruby on Rails with FastCGI.
First things first!
The first thing you'll need to do is setup your ruby environment at Kattare. Please see this FAQ entry: Setting up your Ruby environment with RVMA little about Ruby on Rails
Ruby on Rails can be great. It can also be a huge pain in the tailpipe. Ruby and Rails have proven over the last few years to have a very quickly changing code base and trying to keep up with it all is near impossible even for the seasoned pro. From version to version things WILL break. As we learn more, we'll share what we know here.For now, this has been tested using our system default of Ruby 1.8.6 w/ Rails 0.13.1 and with a RVM environment of Ruby 1.8.7 w/ Rails 2.3.8. Yes, our system default is old, Kattare got into Ruby very early on, and many of our clients have deployed apps on the initial environment. Since then we've been stuck, because nearly every successive version breaks something integral. Which is why RVM is so nice and we're very happy to have it!
Things you'll have to track
In this example,<domainname> = burnside.kattare.com
<document_root> = ~/burnside_kattare_com
<appname> = burnside_on_rails
<controller> = Hello
<username> = burnside
<action> = hello
On the CLI
Here's the play by play from the command line...cd ~<username>
Use the rails command to setup the application base.
rails <appname>
Important! If using rails >= 2.3.3 the fcgi dispatchers are not included unless you specify --with-dispatchers to your rails command.
IE: rails --with-dispatchers <appname>
Link the application base into your document root.
ln -s ../<appname>/public <document_root>/<appname>
vi/pico <appname>/public/.htaccess
change dispatch.cgi to dispatch.fcgi, this will speed things up significantly.
If the .htaccess file does not exist, (rails >= 2.3.3?) here is what the content should be:
AddHandler fastcgi-script .fcgi
Options +FollowSymLinks +ExecCGI
# Redirect all requests not available on the filesystem to Rails
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
# In case Rails experiences terminal errors
# Instead of displaying this message you can supply a file here which will be rendered instead
#
# Example:
ErrorDocument 500 /500.html
Next you need to generate a controller.cd <appname>
./script/generate controller <controller> (my controller is 'Hello')
vi/pico app/controllers/<controller>_controller.rb ('hello_controller.rb' for me.)
class HelloController < ApplicationController def hello end endAnd then you setup a view:
vi/pico app/views/<controller>/<action>.rhtml
<html>
<head>
<title>Hello Rails World</title>
</head>
<body>
<h1>Hello from Rails on Kattare!</h1>
<p>The current time is <%= Time.now %></p>
</body>
</html>
Test!
For my setup, my url came out to be: http://burnside.kattare.com/burnside_on_rails/Hello/helloYours would be something like:
http://<yourdomain>/<appname>/<controller>/<action>
One thing I noticed is that Rails startup IS NOT FAST. In fact, it's so slow that my initial request frequently times out because FastCGI gives up after about 30 seconds. Then if I wait a minute or so, it works.
When your changes are not getting picked up
Sometimes you may need to kill off the fast cgi processes to force the system to restart your app. To do this you execute these commands:killall dispatch.fcgi
killall -9 dispatch.fcgi
If you get a Routing Error
You may need to add the following to your config/environment.rb:After the "Fails::Initializer.run do" line I had to add:
config.action_controller.relative_url_root = "/burnside_on_rails"
For you it would be:
config.action_controller.relative_url_root = "/<appname>"
If your app is not picking up your gems
vi/pico <appname>/public/dispatch.fcgiChange dispatch.fcgi to use gems by changing
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'
to
require 'rubygems'
gem 'fcgi'
require 'fcgi'
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'
You'll want to add the following to the top of the httpd.conf:
LoadModule ruby_module libexec/mod_ruby.so
And if you have an AddModules section:
AddModule mod_ruby.c
Then after the modules have been taken care of:
<IfModule mod_ruby.c>
RubySafeLevel 0 # required for Rails to work...
RubyRequire apache/ruby-run
# Execute *.rbx files as Ruby scripts
<Files *.rbx>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
# Execute *.rbx files as Ruby scripts
<Files *.rb>
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
</Files>
</IfModule>
[Submit a Question]
Comments or feedback? Email: support@kattare.com
Legal: Terms of Service | Privacy Policy | DMCA Procedure | Trademarks



