Here's how I setup a new rails 2.1.0 app on my shared ASO account.
1. Use CPanel to create a new rails app
Make sure to change the install directory to /home/<yourusername>/<appname>
2. SSH into your ASO account
If you don't have SSH access you need to fill out a support ticket with ASO
3. Go into your new application's public/ directory
4. Create and edit the .htaccess file
vim .htaccess
RewriteEngine On
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
5. Go back to application route directory
6. Configure your database.yml (for database connections)
We are using mysql in this example
vim config/database.yml
development:
adapter: mysql
encoding: utf8
database: databasename
username: username
password: password
hostname: servername
test:
adapter: mysql
encoding: utf8
database: test_databasename
username: username
password: password
hostname: servername
production:
adapter: mysql
encoding: utf8
database: prod_databasename
username: username
password: password
hostname: servername
7. Create your first model (this will also generate your migration file)
Pay attention to capitalization and singularity
script/generate model User
8. Edit the migration for this mode
vim db/migrate/migrationname.rb
class CreateUsers < ActiveRecord::Migration
def self.up
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
end
end
def self.down
drop_table "users"
end
end
9. Attempt to migrate your code (create the tables in the database
10. Now create your first controller
script/generate controller user
You can also predefine the list action. This will create the necessary view as well
script/generate controller user list
11. Now set the user controller and list action as your default action.
First remove public/index.html
Uncomment the map.root line in routes.rb
vim config/routes.rb
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
map.root :controller => "user", :action => "list
# See how all your routes lay out with "rake routes"
# Install the default routes as the lowest priority.
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
12. You should be all set, now go learn Rails!
There are no comments on this page. [Add comment]