implemented favorites on post/show page

This commit is contained in:
albert
2011-02-07 18:57:33 -05:00
parent c80df378d8
commit 76a7594a97
16 changed files with 164 additions and 32 deletions

View File

@@ -8,18 +8,12 @@ class FavoritesController < ApplicationController
end
def create
@favorite = Favorite.create(
:user_id => CurrentUser.id,
:post_id => params[:id]
)
Post.find(params[:id]).add_favorite(CurrentUser.user)
render :nothing => true
end
def destroy
Favorite.destroy(
:user_id => CurrentUser.id,
:post_id => params[:id]
)
Post.find(params[:id]).remove_favorite(CurrentUser.user)
render :nothing => true
end
end