Skip to content

Instantly share code, notes, and snippets.

@somazx
Last active December 31, 2018 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somazx/1dbcd48f9fc585ed6b8a84ea6bb48153 to your computer and use it in GitHub Desktop.
Save somazx/1dbcd48f9fc585ed6b8a84ea6bb48153 to your computer and use it in GitHub Desktop.
Improved Rails

Pain Points in Rails

Rails has several pain-points for more complex web applicatoins that frameworks like Hanami and Trailblazer attempt to address. By addressing theses issues your business logic is better isolated from the framework details/implementation, clearer responsibilities, easier reasoning about, cleaner code, creates opportunity for easy further abstraction when necessary, allows for simpler testing, etc.

Identified Pain Points and potential solutions

Better file structure/autoloading that allows grouping of domain concerns under a single folder structure

Solutions: use custom autoload_paths/eager_load_paths in an initializer?

Models are just a "repository" object with associations. No validations, no other methods.

Solutions: Enforce this at the developer/code level - made feasible by using transaction, validation and form objects

Use service/operation objects for business logic in controllers

Solutions: dry-transaction? active_interaction? custom "service objects"?

Use view objects for rendering views

Solutions: draper, dry-view, custom

Use form objects/validation system

Solutions: (reform, dry-validation, custom)

Ability to validate and hyrdate nested json structures to rails model graph.

Lots of json serializers to serialize rails models to json, but no standard for the reverse process.

Solutions: (dry-validation, custom)

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