I have a Rails model that should only allow saving/updating of a model once per day per user. I have a callback to do the Find by user and date then add to errors but this is ugly and feels un-rails-like. I have the typical created_at / updated_at columns (and the time portion is significant/I need to keep it).
So I figure I could either:
1) Create another model attribute which is just the date of creation and scope by that (bleh)
2) Use the :scope attribute but somehow get just the date part of created_at, e.g. validates_uniqueness_of :user, :scope => :created_at.to_date (doesn't work, obviously)
3) Validate unless => Proc.new{ |o| Finder that matches my existing callback } (gross)
http://ar.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000086
There will not be an overwhelming number of these, but I'd rather that it is done in SQL instead of Ruby (for obvious scalability reasons).
Any thoughts? Is there a better way?