Skip to content

What do we need to smooth out file uploads? #1195

Answered by paulcsmith
wout asked this question in General
Discussion options

You must be logged in to vote

I think since file uploads come from a different "part" of the params, we should instead have a different method for defining file attributes called file_attribute :avatar. This would use params.nested_file(:user)[:avatar] as the Avram::PermittedAttribute#value. Since this would now be a regular avram attribute it can be used in forms as expected, you can add errors to it like normal, and you can operate on the UploadedFile by calling avatar.value

This should allow people to do whatever they need with file uploads, and people could build macros on top of it if they want (but I'd probably use a regular method in a before_save or after_save since methods are a lot more flexible.

Does this m…

Replies: 6 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@wout
Comment options

Comment options

You must be logged in to vote
1 reply
@wout
Comment options

Comment options

You must be logged in to vote
1 reply
@wout
Comment options

Answer selected by wout
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants