Sha256: 6f30029f7096d7b9d677908c759bd39877cd75c9197eda96e2b7002d7dfcf0bc
Contents?: true
Size: 920 Bytes
Versions: 12
Compression:
Stored size: 920 Bytes
Contents
class LikesController < ApplicationController # Ensure the suitable tie exists before_filter :tie!, :only => :create # POST /activities/1/like.js 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 def destroy if (@like = activity!.liked_by(current_user).first) @like.destroy end respond_to do |format| format.js end end private def activity @activity ||= Activity.find(params[:activity_id]) end def activity! activity || raise(ActiveRecord::RecordNotFound) end def tie @tie ||= current_user.sent_ties(:receiver => activity!.receiver, :relation => activity!.relation).first end def tie! tie || raise(ActiveRecord::RecordNotFound) end end
Version data entries
12 entries across 12 versions & 1 rubygems