Hacker News new | ask | show | jobs
by JonnieCache 5233 days 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.

1 comments

The gem 'foreigner' makes them painless, and supports Postgres, Oracle, and I think MSSQL.