我想使用devise在用户的显示页面内编辑

时间:2017-09-01 14:46:50

标签: ruby-on-rails ruby devise routes custom-routes

在我的用户的显示页面中,我有一个包含在个人资料中的编辑个人资料标签。我制作了一个Devise控制器,我用它构建了自定义路由。我的问题是现在当我在'users / show /:id'中时它会显示编辑页面。我应该将设计编辑页面视图复制到我的节目视图吗?

我的routes.rb设置如此。

Rails.application.routes.draw do
  devise_scope :teacher do
    get "/teachers/:id" => "devise/registrations#edit" #removed

  end
  devise_for :teachers, controllers: { registrations: 'teachers/registrations' }
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

这是我的控制器

class Teachers::RegistrationsController < Devise::RegistrationsController
  # before_action :configure_sign_up_params, only: [:create],
  # before_action :configure_account_update_params, only: [:update]

  #GET /resource/sign_up
   def new
     super
   end

   def sign_up_params
        params.require(:teacher).permit(:name, :avatar, :email, :password)
   end

   #POST /resource/
   def create
    super
  end

  # GET /resource/edit
  def edit
     super
   end

我想要做的事情的视觉效果低于enter image description here

正如您所看到的,我设置了一个标签来编辑页面中的proD文件。 我是否只是将编辑视图复制到我创建编辑选项卡的节目字段中?

更新

当我将表单呈现到显示页面时,它给了我这个错误。

ActionView::MissingTemplate in Teachers#show
Showing /home/malik/Desktop/NYCDA/docs/week9/teachers-pet/app/views/teachers/show.html.erb where line #163 raised:

Missing partial devise/registrations/_edit with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in:

0 个答案:

没有答案