On 21 Jul 2007, at 08:21, Dan German wrote:> Hi, I was wondering what would be the best way to limit the number of
> file uploads per user using attachment_fu and a :has_many
> relationship.
You could check your threshold in a before_create callback.
E.g. with models User and Upload (this is untested, off the top of my
head):
class Upload < ActiveRecord::Base
belongs_to :user
has_attachment etc.
def before_create
raise "Please no more - the horror!" unless user.uploads.count
< 5
end
end
Regards,
Andy Stewart
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---