2010-11-06 50 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