我对 Rails 有一个非常大的问题。假设我们需要创建一个关于博客的网站,我们允许用户注册,并且用户有自己的管理界面,可以添加、删除、编辑、选择文章和评论。article与的操作comment将来可能会用在其他位置。
所以我们有一个article模型和一个comment模型。
现在我们创建一个用户控制器:
class UserController < ApplicationController
def articleList
end
def articleSave
end
def articleUpdate
end
def articleDestroy
end
def articleEdit
end
def articleAdd
end
def commentList
end
def commentDestroy
end
def commentEdit
end
end
但是不好看,而且当用户管理控件有很多特性的时候,这个用户控制器会很大。我应该创建一个article控制器和comment控制器来处理请求吗?刚刚分离到文章控制器是这样的:
class ArticleController < ApplicationController
def list
end
def save
end
def update
end
def destroy
end
def edit
end
def add
end
end
注释控制器如下:
class CommentController < ApplicationController
def list
end
def destroy
end
def edit
end
def update
end
end
我不知道如何组织结构。