3 ms·
There is nothing to stop you using foreign key constraints with rails, the activerecord migration api includes methods to create them for the major db adapters
by JonnieCache 15y ago
There is nothing to stop you using foreign key constraints with rails, the activerecord migration api includes methods to create them for the major db adapters and there are plugins to automate the process to some extent. It's not the Rails Way™ because it sacrifices some database-agnosticity, and therefore almost noone does it. People achieve the same behaviour with application-level validations in the model.
I'd wager that a lot of the big professional rails deployments are doing FK constraints though.
- jaylevitt 15y agoThe gem 'foreigner' makes them painless, and supports Postgres, Oracle, and I think MSSQL.