This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Common "result" returned by commands | |
class Result | |
attr_accessor :successful, :value, :msg | |
def successful? | |
@successful | |
end | |
def fail(msg) | |
@successful = false | |
@msg = msg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Introducing Commands | |
# The controller is still bloated, but we'll solve that problem later | |
# Here we pull all of the "business logic" into useful abstractions so the controller is easy to read and maintain | |
class Admin::AdminController < ApplicationController | |
before_action :redirect_unless_admin | |
def index | |
render 'index' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is an example of a controller that is doing too many things. | |
# It has a lot of code, and as new features get added this controller continues to bloat | |
class Admin::AdminController < ApplicationController | |
include ApprovalConcern | |
before_action :redirect_unless_admin | |
def index | |
render 'index' | |
end |
NewerOlder