Class: IshManager::FriendsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ish_manager/friends_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#home

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/ish_manager/friends_controller.rb', line 11

def create
  @friend = ::IshModels::UserProfile.find_by( :email => params[:friend][:email] ) # .includes( :shared_galleries )

  authorize! :friends_new, @friend

  me = current_user.profile
  me.friends << @friend
  if me.save
    flash[:notice] = 'Added Friend'
  else
    flash[:alert] = "Cannot add friend: #{me.errors.messages}"
  end
  redirect_to :action => 'index'
end

#indexObject



3
4
5
6
7
8
9
# File 'app/controllers/ish_manager/friends_controller.rb', line 3

def index
  authorize! :friends_index, IshModels::UserProfile
  @new_friend = IshModels::UserProfile.new

  @friends = current_user.profile.friends
  friend_ids = @friends.map &:id
end