Sha256: dcc9483c4a4d149238a8d6dbe31b806ce35c48501be16dd58f043b9415922440

Contents?: true

Size: 902 Bytes

Versions: 129

Compression:

Stored size: 902 Bytes

Contents

class LikesController < ApplicationController
  before_filter :authenticate_user!, :indirect_object

  # POST /activities/1/like.js
  def create
    @like = Like.build(current_subject, current_user, @indirect_id)
    
    respond_to do |format|
      if @like.save
        format.js
      else
        format.js
      end
    end
  end

  # DELETE /activities/1/like.js
  def destroy
    @like = Like.find!(current_subject, @indirect_id)
    
    respond_to do |format|
      if @like.destroy
        format.js
      else
        format.js
      end
    end
  end
  
  private
  
  def indirect_object
    if params[:activity_id].present?
     @indirect_id = Activity.find(params[:activity_id])
    elsif params[:user_id].present?
     @indirect_id = User.find_by_slug!(params[:user_id])
    elsif params[:group_id].present?
     @indirect_id = Group.find_by_slug!(params[:group_id])
    end
  end
end

Version data entries

129 entries across 129 versions & 2 rubygems

Version Path
social_stream-2.2.2 base/app/controllers/likes_controller.rb
social_stream-base-2.2.2 app/controllers/likes_controller.rb
social_stream-2.2.1 base/app/controllers/likes_controller.rb
social_stream-base-2.2.1 app/controllers/likes_controller.rb
social_stream-2.2.0 base/app/controllers/likes_controller.rb
social_stream-base-2.2.0 app/controllers/likes_controller.rb
social_stream-2.1.1 base/app/controllers/likes_controller.rb
social_stream-1.1.12 base/app/controllers/likes_controller.rb
social_stream-base-1.1.11 app/controllers/likes_controller.rb
social_stream-2.1.0 base/app/controllers/likes_controller.rb
social_stream-base-2.1.0 app/controllers/likes_controller.rb
social_stream-2.0.4 base/app/controllers/likes_controller.rb
social_stream-base-2.0.4 app/controllers/likes_controller.rb
social_stream-2.0.3 base/app/controllers/likes_controller.rb
social_stream-base-2.0.3 app/controllers/likes_controller.rb
social_stream-1.1.11 base/app/controllers/likes_controller.rb
social_stream-base-1.1.10 app/controllers/likes_controller.rb
social_stream-1.1.10 base/app/controllers/likes_controller.rb
social_stream-base-1.1.9 app/controllers/likes_controller.rb
social_stream-1.1.9 base/app/controllers/likes_controller.rb