2015-09-14 95 views
2

的错误是:::的ActionView ::模板错误(没有路由匹配{}缺少必需的键:[:编号])

ActionView::Template::Error (No route matches {:action=>"show", :controller=>"users", :id=>#<User id: 21, name: "Test", email: "[email protected]", encrypted_password: "$2a$10$UE170rpnHsdnTOMfBC190uiHQ/ygmLkRxfsTaRMBBT/...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2015-09-14 04:11:22", last_sign_in_at: "2015-09-14 04:11:22", current_sign_in_ip: #<IPAddr: IPv4:128.250.1.8/255.255.255.255>, last_sign_in_ip: #<IPAddr: IPv4:128.250.1.8/255.255.255.255>, created_at: "2015-09-14 04:11:22", updated_at: "2015-09-14 04:11:22">} missing required keys: [:id]):

我认为这个问题是在html代码:

<%= link_to 'Profile', user_path(current_user) %> 

<%= link_to 'Upload Meter Data', user_path(current_user) %> 

但它在本地正常工作。这个问题只发生在heroku。

route.rb

devise_for :users, controllers: { registrations: "users/registrations" } 
    get 'users/import' => 'users#upload_nem12' 
    post 'users/import' => 'users#import_nem12' 
    # user's show page 
    # get 'users/:id' => 'users#show' 
    resources :users, only: [:show], constraints: { id: /\d/ } 
    get 'users/profile' => 'users#show' 

如何解决这个问题呢?

回答

2
resources :users, only: [:show], constraints: { id: /\d/ } 

试试这个:

/\d/ change to /\d+/ 
相关问题