Skip to content

Instantly share code, notes, and snippets.

@clowder
Created August 19, 2012 11:46
Show Gist options
  • Save clowder/3394426 to your computer and use it in GitHub Desktop.
Save clowder/3394426 to your computer and use it in GitHub Desktop.
Pattern Wank
class EntityController < ApplicationController
respond_to :json
def create
entity = Entity.new(post_params)
validator = EntityValidator.new(entity)
if validator.passes?
collection = EntityRepository.add(entity)
respond_with EntityPresenter.new(entity)
else
render :json => validator.errors.to_json, :status => :unprocessable_entity
end
end
end
@clowder
Copy link
Author

clowder commented Aug 19, 2012

Made rookie DDD mistake of conflating Repository Pattern with DDD. Informative exercise all the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment