错误是:
ActionView::Template::Error (No route matches
{:action=>"show", :controller=>"users", :id=>#<User id: 21, name: "Test", email: "test@gmail.com", 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'
如何解决这个问题?