Skip to content

Instantly share code, notes, and snippets.

@inem
Created March 25, 2019 11:23
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 inem/353362a6958ebd23ca24ce59fe33ac03 to your computer and use it in GitHub Desktop.
Save inem/353362a6958ebd23ca24ce59fe33ac03 to your computer and use it in GitHub Desktop.

Material Views as a first class citizens in Rails app

Abstract

Material Views are highly underrated in Rails community. They can save you a lot of time when you deal with a database of complex structure.

Demonstrated solution is cheap, contains no plain SQL, helps to keep business logic within main app. and requires no migrations/versioning

Description

Recently I was in an unpleasant situation – I had to tidy up and speed up a hundred of reports written in a procedural style in one legacy system.

In this talk I want to tell you how I did it and what I learned:

  • How to introduce a new type of classes into app (with M.V. as an example)
  • How not to fall down to SQL and keep all the logic inside application
  • How to work with M.V. without migrations and versioning and be happy with it :)
  • How to turn loads of procedural legacy code into a set of declarative instructions using scopes
  • This talk is about usefulness and applicability of M.V. in Rails apps with examples and technical details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment