How do I make my Ruby on Rails application work?

Post Reply
User avatar
Edge100x
Founder
Founder
Posts: 13009
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

How do I make my Ruby on Rails application work?

Post by Edge100x »

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:
  1. SSH in to the webserver. You can find the information for this on the "File manager" page in your control panel.
  2. 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
    
  3. 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.
    1. Open the Gemfile in your favorite text editor -- nano, for example.

      Code: Select all

      nano Gemfile
    2. Cursor to the end of the file and add these lines:

      Code: Select all

      gem 'sass'
      gem 'tilt'
      gem 'binding_of_caller'
      
    3. Save the file (press Control-X, press 'Y' to confirm the save, and then press enter to confirm the filename).
  4. Create an example controller by entering this command:

    Code: Select all

    bin/rails generate controller Greetings hello
  5. 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".
  6. 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.
    1. Run rake secret to generate a new secret key.

      Code: Select all

      rake secret
    2. 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).
    3. Open config/secrets.yml.

      Code: Select all

      nano config/secrets.yml
    4. At the bottom of the file, you'll see this line:

      Code: Select all

      secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
      Delete everything after the colon, leaving just "secret_key_base: ".
    5. Paste the key that you previously created after the colon (if you are using PuTTY, you can do this with a right-click).
  7. Save the file (press Control-X, press 'Y' to confirm the save, and then press enter to confirm the filename).
  8. 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
Post Reply