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-0.19.2 app/controllers/likes_controller.rb
social_stream-0.25.1 base/app/controllers/likes_controller.rb
social_stream-base-0.19.1 app/controllers/likes_controller.rb
social_stream-0.25.0 base/app/controllers/likes_controller.rb
social_stream-base-0.19.0 app/controllers/likes_controller.rb
social_stream-0.24.1 base/app/controllers/likes_controller.rb
social_stream-base-0.18.1 app/controllers/likes_controller.rb
social_stream-0.24.0 base/app/controllers/likes_controller.rb
social_stream-base-0.18.0 app/controllers/likes_controller.rb
social_stream-0.23.4 base/app/controllers/likes_controller.rb
social_stream-base-0.17.3 app/controllers/likes_controller.rb
social_stream-0.23.3 base/app/controllers/likes_controller.rb
social_stream-base-0.17.2 app/controllers/likes_controller.rb
social_stream-0.23.2 base/app/controllers/likes_controller.rb
social_stream-base-0.17.1 app/controllers/likes_controller.rb
social_stream-0.23.1 base/app/controllers/likes_controller.rb
social_stream-base-0.17.0 app/controllers/likes_controller.rb
social_stream-0.22.1 base/app/controllers/likes_controller.rb
social_stream-base-0.16.4 app/controllers/likes_controller.rb
social_stream-0.22.0 base/app/controllers/likes_controller.rb