Advertisement
ktkaushik

controller.rb

Apr 28th, 2012
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 1.08 KB | None | 0 0
  1. def destroy
  2.     @tag = ActsAsTaggableOn::Tag.find_by_name(params[:name])
  3.     @tag_following = current_user.tag_followings.find_by_tag_id( @tag.id )
  4.     if @tag_following && @tag_following.destroy
  5.     logger.debug "The #{@tag} has been deleted"
  6.       @tag_unfollowed = true
  7.     else
  8.       @tag_unfollowed = false
  9.     end
  10.  
  11.     # if params[:remote]
  12.       respond_to do |format|
  13.         format.js { render 'tags/update' }
  14.         format.any {
  15.           if @tag_unfollowed
  16.             flash[:notice] = I18n.t('tag_followings.destroy.success', :name => params[:name])
  17.           else
  18.             flash[:error] = I18n.t('tag_followings.destroy.failure', :name => params[:name])
  19.           end
  20.           redirect_to tag_path(:name => params[:name])
  21.         }
  22.       end
  23.     # else
  24.     #   if @tag_unfollowed
  25.     #     flash[:notice] = I18n.t('tag_followings.destroy.success', :name => params[:name])
  26.     #   else
  27.     #     flash[:error] = I18n.t('tag_followings.destroy.failure', :name => params[:name])
  28.     #   end
  29.     #   redirect_to tag_path(:name => params[:name])
  30.     # end
  31.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement