2016-06-20 6 views
2

登録コントローラーに余分なページを追加して、ユーザーアカウント設定ページをクリーンアップしました。私の問題は、これらの新しいページでは、ユーザーの属性を更新することはできますが、これらの属性はビューには表示されません。 私は以前に保存された属性がフォーム上の対応する入力に表示されるべきであるという事実を指しています。Ruby on rails。デビーズ登録編集 - ユーザー属性が表示されない

users/editページに残ったフォームの属性には保存された属性が表示されますが、新しいページには表示されません。

私は次のように新しいページを追加しました。

ルート:

devise_for :users, controllers: { registrations: "users/registrations", sessions: "users/sessions" } 
    devise_scope :user do 
    get "https://stackoverflow.com/users/account", to: "users/registrations#account" 
    get "https://stackoverflow.com/users/media", to: "users/registrations#media" 
    get "https://stackoverflow.com/users/notifications", to: "users/registrations#notifications" 
    end 

ユーザ/登録コントローラ。各ページの

def account 
    build_resource({}) 
    respond_with self.resource 
    end 

    def media 
    build_resource({}) 
    respond_with self.resource 
    end 

    def notifications 
    build_resource({}) 
    respond_with self.resource 
    end 

フォーム:

`<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %`> 

なぜ保存された属性は、これらの新しいページに表示されていませんか?

答えて

2

私はそれを理解しました。代わりに使用したの

build_resource({}) 
respond_with self.resource 

私は今、属性が正しく表示され

def account 
     @user = current_user 
     if @user 
      render :account 
     else 
      redirect_to root_url 
     end 
     end 

........etc..... 

を追加しました。

関連する問題