I have a migration for creating a table with around 15 fields in it and all of them should not be null. I was wondering if is there any trick to do that at once instead of declaring :null => false for every single field.
I have a migration for creating a table with around 15 fields in it
Share
Actually, you can do this using
with_options. It’s most commonly used in routes and setting up validations, but it will actually work on any method that takes an options hash as the last argument. So, something like:Here’s the documentation on Object#with_options.