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

José Ney Guerrero
DAK42
Published in
1 min readNov 6, 2019
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.

--

--