scott1028
scott1028

Reputation: 437

how to set rails gem 'rich' upload file size?

this gem from https://github.com/bastiaanterhorst/rich

I setup with rails_admin,but upload file size is 15mb(default). where can i resize it up to 100mb ?

please help me.

Upvotes: 2

Views: 478

Answers (2)

Max Dunn
Max Dunn

Reputation: 1244

This is not easy. Rich hardcodes the validates_attachment_size 15Mb value in rich_file.rb. If you wanted to make the limit smaller, you could add a more restrictive validation like this:

application.rb

config.after_initialize do
  Rich::RichFile.validates_attachment_size(:rich_file, :less_than=>3.megabyte, :message => "must be smaller than 3MB")
end

However, since you want to make the upload size less restrictive, a non-ideal but workable solution is to copy the rich_file.rb model into your rails directory at apps/models/rich/rich_file.rb directory and change the code directly:

rich_file.rb

validates_attachment_size :rich_file, :less_than=>100.megabyte, :message => "must be smaller than 100MB"

Upvotes: 3

Benjamin Tan Wei Hao
Benjamin Tan Wei Hao

Reputation: 9691

Setting it to 100MB is probably a bad idea because the server will most likely timeout after 1 minute or so, unless you push it to a background job, or have some way to keep the current connection alive.

Upvotes: 1

Related Questions