2012-07-24 80 views
0

你好,我正在開發一個關於用戶註冊的應用程序,但是當用戶X想編輯他的信息時,應用程序正在進行「編輯」而不是用戶ID,並向我顯示以下錯誤:ActiveRecord :: RecordNotFound UserController#show

ActiveRecord::RecordNotFound in UserController#show 

Couldn't find User with id=edit 

(我用的設計爲用戶),這是我home.html.rb

<body> 
<div class="container"> 

    <% if signed_in? %> 
    <table class="front" summary="For signed-in users"> 
     <tr> 
     <td class="main"> 
      <h1 class="micropost">What's up?</h1> 
      <%= link_to "edit your profile", edit_user_registration_path, :class => "signup_button round" %> 
     </td> 
     </tr> 
    </table> 
    <% else %> 

    <h1>Sample App</h1> 
    <p> 
    This is the home page for the <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a> sample application. 
    </p> 
    <%= link_to "Sign up now!", new_user_registration_path, :class => "signup_button round" %> 
    <% end %> 
</div> 

這是我的routes.rb(我知道這應該是用戶,但如果我把t帽子複數不`噸工作)

Estaciones::Application.routes.draw do 
root :to => "static_pages#home" 
match '/contact', :to=>'static_pages#contact' 
match '/about', :to=>'static_pages#about' 
get "user/:id" => "User#show" 
devise_for :user 
resources :user do 
end 

最後,這裏是我的UserController的

class UserController < ApplicationController 

def new 
    @user = User.new 
end 

def create 
    @user = User.new(params[:user]) 
    if @user.save 
     redirect_to user_session_path 
    else 
    redirect_to new_user_session_path 
end 

end 

def show 
    @user = User.find(params[:id]) 
    #redirect_to @user 
end 
end 
+0

也是我把跟蹤 應用程序/控制器/ user_controller.rb:18:在'秀」 – Asantoya17 2012-07-24 17:41:10

+0

因爲你有奇異的資源,不會爲多個用戶 – mask8 2012-07-24 17:58:54

+0

感謝一個固定的工作,非常感謝 – Asantoya17 2012-07-24 18:09:50

回答

1

你需要爲了讓Rails生成正確的路線,指定用戶ID。

edit_user_registration_path (USER_ID) 

您沒有將任何user_id傳遞給您的home.html.erb中的方法。

+0

確定我固定:)謝謝 – Asantoya17 2012-07-24 18:10:13

相關問題