Skip to content

Instantly share code, notes, and snippets.

@davidcelis
Created February 13, 2012 07:08
Show Gist options
  • Save davidcelis/1814536 to your computer and use it in GitHub Desktop.
Save davidcelis/1814536 to your computer and use it in GitHub Desktop.
Example recommendable controller implementation
class BeersController < ApplicationController
def like
@beer = Beer.find(params[:id])
respond_to do |format|
if current_user.like @beer
# respond to HTML with a redirect, render ajax js, etc.
else
# flash[:error], if you wish
end
end
end
def dislike
@beer = Beer.find(params[:id])
respond_to do |format|
if current_user.dislike @beer
# respond to HTML with a redirect, render ajax js, etc.
else
# flash[:error], if you wish
end
end
end
# etc.
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment