Displaying 1 result from an estimated 1 matches for "img_field".
Did you mean:
id_field
2006 Apr 10
3
Upload an image
...user][:img].read
@user = User.new(params[:user])
if @user.save
...
It reads the content of the file, saves it ok, but two questions:
First, is it ok to read on the controller? I saw samples on both the
controller and the model (on the model it just did not worked for me -
using img_field.read gives an error telling me
undefined method `read'' for #<String:0xb651c3d4>
Second, how, with just those two fields, with no other field on the form
with content-type and so on (I saw some samples with that), make sure
that the user will only upload, for example, PNG files? I m...