Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Nick Fedoroff1,939 Points
Error in user_friendship_controller_test.rb "undefined method 'empty?' for nil:NilClas
My test keeps failing because of the error in the title. Another user had this same issue, but he determined it was due to a typo. As far as I can tell, my test is correct. Here's my user_freindships_controller.rb.
class UserFriendshipsController < ApplicationController before_filter :authenticate_user!, only: [:new] def new if params[:friend_id] @friend = User.where(profile_name: params[:friend_id]).first raise ActiveRecord::RecordNotFound if @friend.nil? @user_friendship = current_user.user_friendships.new(friend: @friend) else flash[:error] = "Friend Required" end rescue ActiveRecord::RecordNotFound render file: 'public/404', status: :not_found end def create if params[:friend_id] else flash[:error] = "Friend required" redirect_to root_path end end end
Christopher Peters1,927 Points
Not sure if this is it but at least syntactically,
:status => :not_found
At least I think. I don't believe this affects functionality, though.