Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在设计注册后重定向到编辑_配置文件_Ruby On Rails_Ruby On Rails 4_Devise_Routes - Fatal编程技术网

Ruby on rails 在设计注册后重定向到编辑_配置文件

Ruby on rails 在设计注册后重定向到编辑_配置文件,ruby-on-rails,ruby-on-rails-4,devise,routes,Ruby On Rails,Ruby On Rails 4,Devise,Routes,我正试图让我的rails应用程序在通过Desive注册后重定向到edit_profile_路径,但在尝试解决方法时遇到了严重问题。我在这里花了四个小时试图找到解决方案,但似乎找不到问题所在 My current routes.rb: resources :users, :only => [:index] do member do get :favourite_users, :favourited_users end resources :posts

我正试图让我的rails应用程序在通过Desive注册后重定向到edit_profile_路径,但在尝试解决方法时遇到了严重问题。我在这里花了四个小时试图找到解决方案,但似乎找不到问题所在

My current routes.rb:

   resources :users, :only => [:index] do
    member do
      get :favourite_users, :favourited_users
    end
    resources :posts
    resources :profiles, only: [:show, :edit] 
  end
我的注册控制器.rb

class RegistrationsController < Devise::RegistrationsController

  protected

  def after_sign_up_path_for(resource)
    edit_profile_path(resource)
  end
end
class ProfilesController < ApplicationController

    def new
        @profile = Profile.new
    end

    def show
    end

    def profile
    end

    def edit
        @profile = current_user.profile
    end
end

任何帮助都将不胜感激

您是否尝试过从控制台运行以下命令:

rake routes
这将输出应用程序知道的所有路由。我希望在没有格式的情况下,我很难阅读您的routes文件,但是由于它是嵌套的route,我认为您实际上想要使用

edit_user_profile_path(resource)

我以前尝试过这个,但得到的结果是:没有路由匹配{:action=>edit,:controller=>profiles,:user_id=>nil}缺少必需的键:[:id]。Rake routes显示我拥有的路由是edit_profile profilesedit,因此我使用edit_profile_path。有什么帮助吗?对不起,我一开始读错了。您希望用户只有一个配置文件还是多个配置文件?如果您希望一个用户只有一个配置文件,那么您需要将路由更新为“资源配置文件”,而不是“资源配置文件”。看见编辑用户配置文件路径资源在此之后应该可以工作。啊,太棒了!我还必须将profile.html.erb顶行更改为已阅读您添加的链接。现在可以了,谢谢!
undefined method `profile_path' for #<#<Class:0xb50b8618>:0xb50abe54>
No route matches {:action=>"edit", :controller=>"profiles"} missing required keys: [:id]
rake routes
edit_user_profile_path(resource)