Ruby on Rails

Ruby on Rails is a web application model-view-controller (MVC) framework written in MIT License. This is a very efficient way of developing successful web applications in a short period of time. All benefits of Ruby on Rails can be possible by utilizing our more dedicated hosting platforms. Please feel free to check out our products and features at the links below:

https://www.ixwebhosting.com/cloud-solutions

https://www.cloudbyix.com/features

However, it is possible to run simple RoR applications on our Shared Linux plans for testing purposes.

How to run Ruby on Rails application on Shared Hosting?

1.) Firstly please log in your account with us > go to My Products section > click on Manage button under your Hosting plan > click on Web options icon from control panel and select your domain name if you have more than one > enable RoR support for a domain name in the question.

 

enable_ruby

NOTE: Enabling Ruby On Rails resource will replace your current index.html file with Ruby’s default one.

2.) On this step it is necessary to make sure that all components are installed.

Please hit FTP Manager icon on your control panel:   

ftp_managerThen enable crontab:

crontab_enable

 Now you need to find out where Ruby’s gems are located exactly on your account.

Then run this command in cron:

 which gem or where is gem 

setting_crontab

NOTE: Do not forget to remove cron command when you receive an email.

As a result you will see correct path to gems. It could be /usr/bin/gem or /usr/local/bin/gem. It depends on your account configurations. According to these results, you need to execute the following command in cron:

 /usr/bin/gem list

or

/usr/local/bin/gem list

As a result we should get list of components like you can see bellow. In case some components are missing (i.e. mysql) RoR application may not work. Please feel free to contact us at any time and we will be happy to install missing components for you but only in case your application will not start properly after all the steps.

Here is an example of result from cron:

* LOCAL GEMS * actionmailer (2.1.2) actionpack (2.1.2) activerecord (2.1.2) activeresource (2.1.2) activesupport (2.1.2) mysql (2.7) rails (2.1.2) rake (0.8.7)

ruby version – 1.8.5 (2006-08-25) [x86_64-linux]

gem version – 1.3.5

3.) Please create MySQL database from your control panel.

Here is a manual which would be helpful for you: http://www.ixwebhosting.com/support/st_kb/how-to-create-a-mysql-database/

Then go to /hsphere/local/home/ftp_username/ruby/domain.com folder, and modify config/database.yml file with correct Database connection settings for all modes.

NOTE: Please make sure to replace ftp_username and domain.com with information from your account.

Development:

adapter: mysql
database: username_ruby
username: username_ruby
password: pass
host: mysqlXXX.ixwebhosting.com

Test:

adapter: mysql
database: username_ruby
username: username_ruby
password: pass
host: mysqlXXX.ixwebhosting.com

Production:

adapter: mysql
database: username_ruby
username: username_ruby
password: pass
host: mysqlXXX.ixwebhosting.com

Finding your MySQL Database Information article could be helpful for you in this case:

http://www.ixwebhosting.com/support/st_kb/finding-your-database-information/

NOTE: You can utilize the same database for all nodes or you can make them each different if necessary.

4.) Next, modify config/routes.rb file so that the code will look like this:

map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:id.:format’
map.root :controller => “home”
end

NOTE: by default it ends on:

map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:id.:format’
end

5.) Then execute in Cron following command:

cd /hsphere/local/home/ftp_username/ruby/domain.com/;/usr/bin/ruby script/generate controller home index;/usr/bin/rake db:migrate

NOTE: Please make sure to replace “ftp_username” and “domain.com” with information from your account.

6.) Isert the following code into into public/index.html file:

<h1>Hello, Rails!</h1>

- Run http://domain.com/ and you will see → “Hello, Rails!”

- Run http://domain.com/home and you will see “Home#index Find me in app/views/home/index.html.erb”

So, it WORKS!

7.) Now to generate Ruby posts execute in cron

cd /hsphere/local/home/ftp_username/ruby/domain.com/;/usr/bin/ruby script/generate controller home index;/usr/bin/rake db:migrate

NOTE: Please make sure to replace “ftp_username” and “domain.com” with information from your account.

8.) Insert into app/views/home/index.html.erb the following code:

<h1>Hello, Rails!</h1> <%= link_to ‘My Blog’, posts_path %>

- Run http://domain.com/home and you will see: “Hello, Rails! My Blog”

- Click on My Blog and it will redirect you to http://domain.com/posts where you can submit your posts.

If there are some problems with the configuration of your site, please contact our support department for assistance with troubleshooting the issue:

http://www.ixwebhosting.com/support/

Was this article helpful?

Yes (14)
No (0)

We're sorry you didn't find this article very helpful. Please help us improve it by leaving your feedback below.

Error