Create a new Rails app via SSH
Note: if you don't have SSH access you need to fill out a support ticket with us to gain access.
Move into your home directory (if you just logged in, you are already there):
Create the directory that holds your Rails application
Note: MyApp can be changed to whatever you would like, but whatever you choose needs to stay the same wherever you type MyApp.
rails new myapp
rails new -h (to see all rails commands)
Link your Rails application into your web directory so that you may access the Rails application on your website:
ln -s ../myapp/public myapp
Let the server know about your Rails application by opening up the file located at myapp/public/.htaccess
Note: you can access this over FTP or by using the nano or vi commands over SSH. This file shouldn't already exist in the system. If it does, you can empty it's contents.
Put this as the entire contents of the file:
Create your needed models, controllers, and views for your application
Note: models are the objects, which will usually be linked to a table in your database.
A model can be created used the following command:
rails generate model User
Note: a controller is what moves data between the model (database) and your view.
A controller can be created using the following code:
rails generate controller User
Note: the view is where you will control what the user sees.
The view can either be created manually or with help of the generator:
rails generate controller User list
The above code would create the controller for the User object and it will also create the needed code for the list view.
If you would like to manually create this edit the User controller file, found at app/controllers/user_controller.rb, by entering the following code within the class (after class and before end):
Create app/views/user/list.rhtml to allow you to view the list action at http://www.example.com/myapp/user/list (replace "example.com" with your domain)
Configure your database.yml for database connections (we are using MySQL in this example):
Create your first model (this will also generate your migration file)
script/generate model User
Edit the migration for this mode
class CreateUsers < ActiveRecord::Migration
create_table "users", :force => true do |t|
t.column :login, :string
t.column :email, :string
t.column :created_at, :datetime
t.column :updated_at, :datetime
Attempt to migrate your code (create the tables in the database)
Create your first controller
rails generate controller user
You can also predefine the list action. This will create the necessary view as well:
rails controller user list
Set the user controller and list action as your default action by first removing public/index.html and then uncommenting the map.root line in routes.rb:
You can have the root of your site routed with 'map.root', just remember to delete 'public/index.html'
Install the default routes as the lowest priority: map.root :controller => "user", :action => "list