I currently have a Rails app in which users of different ranks can upload files (via Paperclip). I know I can set a global file size limit in the model, however I'm looking to enforce different file size limits depending on the users' rank.
Does anyone know how I can accomplis开发者_运维问答h this?
The easiest answer is that you write activerecord validations. e.g. write following at model:
validate :some_name
def some_name
errors_add(:file_file_size, 'error message') if file_file_size > 2.megabytes && user.rank > ...
end
精彩评论