Sha256: 44c6d03ad51f70e6138076ad2c8eecc30d11bf9af283a6cd0f076ffcc43f77da
Contents?: true
Size: 876 Bytes
Versions: 8
Compression:
Stored size: 876 Bytes
Contents
class FavoritesController < BaseController before_filter :login_required, :only => [:destroy] before_filter :find_user, :only => [:show, :index] cache_sweeper :favorite_sweeper, :only => [:create, :destroy] def create @favoritable = params[:favoritable_type].classify.constantize.find(params[:favoritable_id]) @favorite = Favorite.new(:ip_address => request.remote_ip, :favoritable => @favoritable ) @favorite.user = current_user || nil @favorite.save respond_to do |format| format.js end end def destroy @favorite = current_user.favorites.find(params[:id]) @favorite.destroy respond_to do |format| format.js end end def show @favorite = @user.favorites.find(params[:id]) end def index @favorites = Favorite.recent.by_user(@user).page(params[:page]) end end
Version data entries
8 entries across 8 versions & 1 rubygems