Rspec / Device / Cucumberテンプレートアプリの使用ログイン時に、ユーザーがusers#indexmyroutesファイルにリダイレクトされるようにします。
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
current_userヘルパーメソッドを使用する代わりに「@user=User.find(params [:id])」を追加しようとしましたが、まだ問題があります
ビューの下のユーザーフォルダにあるショービューは
<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>