我对Rails有一个很大的疑问。假设我们需要创建一个关于博客的网站,我们允许用户注册,并且用户有他们自己的管理界面,这使得他们可以添加,删除,编辑和选择文章和评论。 article
和comment
上的操作可能会在将来用于其他位置。如何组织Rails结构
所以我们有一个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
但din't好看,当用户管理控制有许多功能,该用户控制器将是非常大的。我应该创建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
我不知道如何组织结构。