我對rails非常陌生,並且正在編輯最初由其他人編寫的代碼,所以我可能需要比普通人更深入的響應。 。沒有路由匹配丟失所需的鍵:[:id]
我遇到這個錯誤,當我運行rake: No route matches {:controller=>"users", :action=>"show", :id=>nil, :format=>nil} missing required keys: [:id]
,似乎是引起該問題的線路是這樣的:
<%= link_to("My Account", user_path(current_user)) %>
鏈路的實際工作正常上羅calhost,但未能在該行本次測試「渲染:模板」:
it "renders new initiative form" do
assign(:initiative, Initiative.new(location: Location.new,rewards: [FactoryGirl.create(:reward)]))
render :template => "initiatives/new.html.erb" (...etc.)
不知道還有什麼是有用的,包括在這裏,但UsersController是:從耙路線
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
end
和結果:
`batch_action_admin_users POST /admin/users/batch_action(.:format) admin/users#batch_action
admin_users GET /admin/users(.:format) admin/users#index
POST /admin/users(.:format) admin/users#create
new_admin_user GET /admin/users/new(.:format) admin/users#new
edit_admin_user GET /admin/users/:id/edit(.:format) admin/users#edit
admin_user GET /admin/users/:id(.:format) admin/users#show
PATCH /admin/users/:id(.:format) admin/users#update
PUT /admin/users/:id(.:format) admin/users#update
DELETE /admin/users/:id(.:format) admin/users#destroy
batch_action_admin_comments POST /admin/comments/batch_action(.:format) admin/comments#batch_action
admin_comments GET /admin/comments(.:format) admin/comments#index
POST /admin/comments(.:format) admin/comments#create
admin_comment GET /admin/comments/:id(.:format) admin/comments#show
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_omniauth_authorize GET|POST /users/auth/:provider(.:format) omniauth_callbacks#passthru {:provider=>/twitter|facebook/}
user_omniauth_callback GET|POST /users/auth/:action/callback(.:format) omniauth_callbacks#(?-mix:twitter|facebook)
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) registrations#cancel
user_registration POST /users(.:format) registrations#create
new_user_registration GET /users/sign_up(.:format) registrations#new
edit_user_registration GET /users/edit(.:format) registrations#edit
PATCH /users(.:format) registrations#update
PUT /users(.:format) registrations#update
DELETE /users(.:format) registrations#destroy
user GET /users/:id(.:format) users#show`
也許有人可以幫忙嗎?
當您未登錄時,會發生這種情況嗎(又名current_user == n) – 2014-09-10 15:05:46