Acts_as_attachment and validations / errors

I tried to upload an image, that was about 1.5mb in size. It would not upload and I could not figure out why. Then I saw the docs that said by default the max size is 1 mb. Fine, setting the :max_size to 2.megabytes let me upload my image.

My question however, is how do I trap that error / validation error? I'm sure it's something simple that I'm overlooking.

Should be a validation error like any other. It's just validates_inclusion_of :size...

Thanks.

In the else statement of the save I redirected back to the "new" page and I put an <%= error_messages_for :book_cover %> But didn't see anything displayed. I'll have to play around some more..

john

Thanks.

In the else statement of the save I redirected back to the "new" page and I put an <%= error_messages_for :book_cover %> But didn't see anything displayed. I'll have to play around some more..

john

Redirecting will start a brand new request that usually creates a new instance of your record, losing any error messages in the process. You can use render :action => 'new' to show the form again, yet your @book_cover record maintains its state from the #create action.

Ah, ok. Like I said, I was getting confused. That's what I get from copying and pasting from various places :slight_smile:

Thanks!

John