我想知道是否有人可以解决我遇到的一些问题?我创建了一个 Rails 应用程序:
rails myapp -d mysql
cd myapp
haml --rails .
rake db:create:all
然后我想用一个mysql客户端来创建表。让我们说用户和客户。客户也是用户,因此您具有如下架构:
users
----------------
id int, not null, primary key, auto increment
first_name varchar(50) not null
last_name varchar(50) not null
email varchar(50) not null unique
password varchar(50) not null
created_at datetime not null
updated_at datetime not null
customers
----------------
id int, not null, primary key, auto increment
user_id int, unique
-- some other stuff that is customer specific
我需要运行哪些 Rails 脚本命令才能在我的 Rails 应用程序下创建并完全填写模型、视图和控制器?我试过这个:
ruby script/generate scaffold user
ruby script/generate scaffold customer
创建文件但模型为空:
class User < ActiveRecord::Base
end
这是怎么回事?另外,我想创建一个管理部分来管理东西。我发现我需要为这些添加路线:
map.namespace :admin do |admin|
admin.resources :users
admin.resources :customers
end
我还需要什么才能让管理部分正常运行?这里还有我正在运行的 ruby/gems 版本:
ruby 1.8.6
rails 2.3.5 & 2.3.2 <- I'm using 2.3.2 because haml
wasn't working (or some other plugin) with 2.3.5
haml 2.2.15
rspec 1.2.9 <- I saw from another thread that I might need
this when creating an adminstration section (rspec_controller etc)