Displaying 1 result from an estimated 1 matches for "m002171".
Did you mean:
002171
2009 Nov 20
3
Ensuring that foreign key is valid
I am trying to set up a validation in a model to ensure that a record
can''t be saved unless the foreign key it belongs_to is a valid record.
My model says:
class Admin < ActiveRecord::Base
validates_presence_of :user_id
validates_numericality_of :user_id
validates_uniqueness_of :user_id
validates_associated :user
belongs_to :user
end
but I can still create an admin