每次都會忘掉
氣死我了, 每次都會忘掉怎麼用ruby on rails, 老了, 還是寫下來的好
1. rails testrails
2. in config\database.yml
development:
adapter: mysql
database: account
username: root
password:
host: localhost
test:
adapter: mysql
database: account_test
username: root
password:
host: localhost
production:
development
3. ruby script\generate model user
4. in db\migrate
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.column :login, :string
t.column :password, :string
t.column :created_at, :datetime
end
end
def self.down
drop_table :users
end
end
5. rake db:migrate
6. ruby script\generate controller user
7. scaffold in controller
class UserController < ApplicationController
scaffold :user
end
8. ruby script/server
9. browse to http://localhost:3000/user
10. ruby script\generate scaffold user
11. edit those controllers
12. browse to http://localhost:3000/users
接下來可以試試看下面這個tutorial 教你怎麼弄 belongs_to 和 has_many 以及幫資料分categories會用到的rhtml
http://www.aptana.com/docs/index.php/Setting_up_the_Cookbook_database_in_RadRails
沒有留言:
張貼留言