开发者

Rails & Paperclip: Variable File Size Limit

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜