How do I make my Ruby on Rails application work?
Posted: Thu Apr 16, 2009 10:14 pm
If you have an existing RoR application, you should be able to create a new subdomain, with a new folder name specified, for one of your domains through the Domains page and then upload the application to that folder via FTP. When you visit the site, your RoR application should automatically execute.
If you've never used RoR before, you can create an example Ruby on Rails application by following these instructions:
If you've never used RoR before, you can create an example Ruby on Rails application by following these instructions:
- SSH in to the webserver. You can find the information for this on the "File manager" page in your control panel.
- Run these commands from the home folder to perform most of the initial rails install and change to its directory:
Code: Select all
rails new hello --skip-spring cd hello
- Rails comes with a Gemfile that is broken by default, preventing applications from loading a few important dependencies. We'll need to edit that file.
- Open the Gemfile in your favorite text editor -- nano, for example.
Code: Select all
nano Gemfile
- Cursor to the end of the file and add these lines:
Code: Select all
gem 'sass' gem 'tilt' gem 'binding_of_caller'
- Save the file (press Control-X, press 'Y' to confirm the save, and then press enter to confirm the filename).
- Open the Gemfile in your favorite text editor -- nano, for example.
- Create an example controller by entering this command:
Code: Select all
bin/rails generate controller Greetings hello
- Create a new subdomain through the Domains page in your control panel. For instance, you could define "hello.yourdomain.com". Point its "Folder" to "hello/public".
- Configure a secret key for production use. If you don't do this, you'll see an "Incomplete response received from application" error when you try to load it in your browser.
- Run rake secret to generate a new secret key.
Code: Select all
rake secret
- Copy the key that it created and printed into your clipboard (if you are using PuTTY, you can do this by selecting it with your mouse).
- Open config/secrets.yml.
Code: Select all
nano config/secrets.yml
- At the bottom of the file, you'll see this line:
Delete everything after the colon, leaving just "secret_key_base: ".
Code: Select all
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
- Paste the key that you previously created after the colon (if you are using PuTTY, you can do this with a right-click).
- Run rake secret to generate a new secret key.
- Save the file (press Control-X, press 'Y' to confirm the save, and then press enter to confirm the filename).
- Visit http://hello.yourdomain.com/hello. The rails app will automatically be detected and it should print something like this:
Greetings#hello
Find me in app/views/greetings/hello.html.erb