Class: LikesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/likes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /activities/1/like.js



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/likes_controller.rb', line 6

def create
  @like = activity!.children.new :verb => "like"

  respond_to do |format|
    if @like.save
      tie!.activities << @like
      format.js
    else
      format.js
    end
  end
end

#destroyObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/likes_controller.rb', line 19

def destroy
  if (@like = activity!.liked_by(current_user).first)
    @like.destroy
  end

  respond_to do |format|
    format.js
  end
end