app/controllers/posts_controller.rb
# We don't want anybody anonymous to create new Posts.
# So in all child controllers this filter will work fine. 
We don't want anybody anonymous to create new Posts.
So in all child controllers this filter will work fine.
We don ' t want anybody anonymous to create new Posts . So in all child controllers this filter will work fine .
def toggle_favourite
    @post = Post.find(params[:post_id])
    if current_user.has_favourite?(@post)
      current_user.remove_favourite!(@post)
    else
      current_user.add_favourite!(@post)
    end
    respond_to do |format|
      format.js
    end
  end
def toggle_favourite @post = Post . find ( params [ :post_id ] ) if current_user . has_favourite? ( @post ) current_user . remove_favourite! ( @post ) else current_user . add_favourite! ( @post ) end respond_to do | format | format . js end end
We don't want anybody anonymous to create new Posts.
We don ' t want anybody anonymous to create new Posts .