Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

validations to assert valid assoications #101

wants to merge 1 commit into


None yet
2 participants

patrickdavey commented Mar 10, 2012

Changing the validations so that the models check that the foreign keys are present and also valid.


malclocke commented Mar 17, 2012

Hi Patrick,

What's the motivation behind this?


patrickdavey commented Mar 17, 2012

No major motivation other than what I think is correctness?
validates :project_id, :presence => true

Just checks that the project_id is there. If you sent it a string it'll convert it to zero and happily save the record.
validates_presence_of :project

Checks that there is a valid association to an existing project.. so you can't save the record with bogus data. It's probably academic as there's no way through the interface to actually send bad data, but I think it's more correct to have the validates_presence_of....


malclocke commented Mar 18, 2012

Ok, cool. I'm afraid I didn't get to merge this before I replaced TestUnit with rspec. Do you fancy rerolling it against the current master using rspec?


patrickdavey commented Jan 22, 2013

closing this as committed #147 against current master using rpsec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment