使用Rspec / Device / Cucumber模板应用 登录后,我希望将用户重定向到用户#index 我的路线文件
Engage::Application.routes.draw do
authenticated :user do
root to: 'users#show'
end
root :to => "home#index"
devise_for :users
resources :users, only: [:index]
resources :agendas, only: [:create, :destroy]
end
登录后我收到错误
ActiveRecord::RecordNotFound in UsersController#show
Couldn't find User without an ID
我的users_controller
class UsersController < ApplicationController
before_filter :authenticate_user!
def index
@user = current_user
@agendas = @user.agendas
end
end
我尝试添加“@user = User.find(params [:id])”而不是使用current_user辅助方法,但我仍然遇到问题
我在视图下的用户文件夹中显示的视图是
<div class="row">
<div class="span8">
<% if @user.agendas.any? %>
<h2>Agendas (<%= @user.agendas.count %>)</h2>
<ol class="agendas">
<%= render @agendas %>
</ol>
<% end %>
</div>
</div>
答案 0 :(得分:1)