I have a 'urlsafe' column in my database. This is a string that gets created off of a company name field aptly called...'name'.
In my model I have the following:
My problem above comes from the fact I'm stuck wanting to run the first validation to make sure i have a name there, then run the generate_urlname function, and then finally validate the uniquenesss. But since I either have to call the before_save or validate, I can't have both!Code:validates_presence_of :name, :phone, etc.. # make sure all elements are there to save (not urlname though, as this is created by the program) validates_uniqueness_of :urlname, :scope => [:city_safe, :address_state] #make sure there are no other businesses with the urlname, in that city, in that state before_save :generate_urlname # generate the urlname from the company name
I've looked at all the before_save, after_save, etc calls I could make, but none seem to work. I saw you can create your own validation, but I can't find anywhere that explains how to throw that it doesn't validate if you create your own?
Thanks for any suggestions.![]()





Bookmarks