Skip to content

Instantly share code, notes, and snippets.

@jagdeepsingh
Created December 26, 2015 14:00
Show Gist options
  • Save jagdeepsingh/a7b2941db0f51226578a to your computer and use it in GitHub Desktop.
Save jagdeepsingh/a7b2941db0f51226578a to your computer and use it in GitHub Desktop.
Create a service in rails
class ReservationService
class CustomError < StandardError; end
def initialize(options = {})
add_logic_here
end
def validate!
raise CustomError unless valid?
end
private
def valid?
validation_logic_here
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment