2010-11-06 51 views
1

我有一個Rails 3應用與設計......的Rails 3 - 設置帳戶控制器rw查看

我想創建一個帳戶控制器將允許用戶更新他們的帳戶,像個人資料,賬戶,通知,密碼等...

這是我到目前爲止所做的。

我產生這給了我下面的帳戶控制器:

路線: 現在存在與/視圖/帳戶給上面的名稱

get "account/profile" 
    get "account/password" 
    get "account/notices" 

查看/ ...

我的控制器

class AccountController < ApplicationController 

    before_filter :authenticate_user! 

    def profile 
    @user = User.find(current_user.id) 
    end 

    def password 
    end 

    def notices 
    end 

    def privacy 
    end 

    def disable 
    end 

end 

信息查看賬戶資料:

<% form_for @user, :html => { :multipart => true} do |f| %> 

問題是,使格式如:

<form accept-charset="UTF-8" action="https://stackoverflow.com/users/13" class="edit_user" enctype="multipart/form-data" id="edit_user_13" method="post"> 

而且我希望它像/account/profile/update這哪裏是形式要張貼檢查?

這是我第一次做這樣的事情。我在正確的軌道上?如何添加/ account/profile/update部分?在路線中添加一些內容並更改表單標籤?在路線中有沒有更乾淨的方法?

謝謝

回答

2

如果可能,您應該堅持使用RESTful路由。 http://edgeguides.rubyonrails.org/routing.html

而且,看看在你的路由使用嵌套的資源:而不是像​​網址,REST風格的選擇將使用HTTP PUT

讀這對於Rails的3 REST風格的路由的詳細信息是/profile/123配置文件,通知等(在軌DOC 2.7節):

resources :accounts do 
    resources :profiles, :notices 
end 

例如,使用嵌套的資源做一個編輯會給你的路線是這樣的:

/accounts/123/notices/3/edit