As you see I have validates :sector, :presence => true.
When I create a new Category, if I don’t select a sector I have an
error page with the message:
Couldn’t find Sector with ID=
But there is the validates, why I don’t have the message sector can’t be
blank?
As you see I have validates :sector, :presence => true.
When I create a new Category, if I don’t select a sector I have an
error page with the message:
I don’t know about the others but when associating other tables like
this, I
don’t do the validations
this way.
i create a method that i can call with validates.
validates :sector_should_not_be_blank
def sector_should_not_be_blank
errors.add(:sector, “can’t be blank”) if sector.nil?
end
As you see I have validates :sector, :presence => true.
When I create a new Category, if I don’t select a sector I have an
error page with the message:
Couldn’t find Sector with ID=
Is that error occurring before the save happens, or are you saying
that it has saved it with no sector?