1
0
Fork 0

More verbose notices

This commit is contained in:
Andrew Tomaka 2014-10-27 12:43:24 -04:00
parent b3640e078c
commit 01d6c0e97d
2 changed files with 6 additions and 2 deletions

View file

@ -9,10 +9,10 @@ class FriendshipsController < ApplicationController
@friendship = current_user.friendships.build(friendship_params)
if @friendship.save
flash[:notice] = 'Added friend.'
flash[:success] = "#{@friendship.friend.name} added as friend"
redirect_to friendships_path
else
flash[:notice] = 'Unable to add friend.'
flash[:error] = "Unable to add friend: #{@friendship.error_messages}"
redirect_to users_path
end
end

View file

@ -10,4 +10,8 @@ class Friendship < ActiveRecord::Base
errors.add(:friend_id, 'cannot refer back to self')
end
end
def error_messages
errors.full_messages.join(', ')
end
end