2013-09-27 99 views
0

我對Rails有一個很大的疑問。假設我們需要創建一個關於博客的網站,我們允許用戶註冊,並且用戶有他們自己的管理界面,這使得他們可以添加,刪除,編輯和選擇文章和評論。 articlecomment上的操作可能會在將來用於其他位置。如何組織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 

我不知道如何組織結構。

回答