Tip: Phasing Out old legacy models in Rails — Read Only Method

José Ney Guerrero
Nov 6 · 1 min read
Photo by Samuel Castro on Unsplash

Most of the time, when you’re working with a legacy project or database is necessary to access those old models until a full migration is completed, but this could lead to trouble, so you’ll want to make sure that the new app can’t write changes to that old model just to be safe.

There’s an easy way to do that, just by defining a readonly? method in the model, ActiveRecord will keep away all those methods that can change data.

And… you’re safe

There’s an easy way to do that, just by defining a readonly? method in the model, ActiveRecord will keep away all those methods that can change data.

DAK42

Exploring technology, software development and sharing it with everybody

José Ney Guerrero

Written by

Hacking life one commit at a time

DAK42

DAK42

Exploring technology, software development and sharing it with everybody

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade