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-base-1.1.8 app/controllers/likes_controller.rb
social_stream-1.1.8 base/app/controllers/likes_controller.rb
social_stream-base-1.1.7 app/controllers/likes_controller.rb
social_stream-2.0.2 base/app/controllers/likes_controller.rb
social_stream-base-2.0.2 app/controllers/likes_controller.rb
social_stream-2.0.1 base/app/controllers/likes_controller.rb
social_stream-base-2.0.1 app/controllers/likes_controller.rb
social_stream-2.0.0 base/app/controllers/likes_controller.rb
social_stream-base-2.0.0 app/controllers/likes_controller.rb
social_stream-2.0.0.beta3 base/app/controllers/likes_controller.rb
social_stream-base-2.0.0.beta3 app/controllers/likes_controller.rb
social_stream-2.0.0.beta2 base/app/controllers/likes_controller.rb
social_stream-base-2.0.0.beta2 app/controllers/likes_controller.rb
social_stream-2.0.0.beta1 base/app/controllers/likes_controller.rb
social_stream-base-2.0.0.beta1 app/controllers/likes_controller.rb
social_stream-1.1.7 base/app/controllers/likes_controller.rb
social_stream-base-1.1.6 app/controllers/likes_controller.rb
social_stream-1.1.6 base/app/controllers/likes_controller.rb
social_stream-base-1.1.5 app/controllers/likes_controller.rb
social_stream-1.1.5 base/app/controllers/likes_controller.rb