More verbose notices
This commit is contained in:
parent
b3640e078c
commit
01d6c0e97d
2 changed files with 6 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue