Skip to content

Instantly share code, notes, and snippets.

@nthx
Created January 11, 2012 13:12
Show Gist options
  • Save nthx/1594592 to your computer and use it in GitHub Desktop.
Save nthx/1594592 to your computer and use it in GitHub Desktop.
DRY anti 1
#example of BAD code duplication among 2 controllers
#that could be at least extracted to 1 base controller
#and /:show game.name/ should be used
class A::Controller
before_filter :check_perms
def set_points
player.set_points params[:points]
redirect_to :action => :index
end
def reset_questions
game.reset_questions
redirect_to :action => :show 'battlefield3'
end
end
class B::Controller
before_filter :check_perms
def set_points
player.set_points params[:points]
redirect_to :action => :index
end
def reset_questions
game.reset_questions
redirect_to :action => :show 'mw3'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment