I am using this code for uploading the profile image of a user
if params[:user][:image].present?
uploaded_io = params[:user][:image]
name = "image_" << @user.username << uploaded_io.original_filename
File.open(Rails.root.join('public', 'images','profile',name ), 'w') do |file|
file.write(uploaded_io.read)
end
end
but its giving this error when i run it cannot convert ascii-8bit to utf-8bit
so what i did was i changed my default encoding in application.rb file like this config.encoding = "ascii-8bit" from config.encoding = "utf-8". and it started working fine.
But the problem is now I am sending a mail to the user for successful registeration from simple rails mailer and now before sending the mail its giving me this error cannot convert utf-8bit to ascii-8bit.
Now I am totally struck only one of them works at one time. I have tried a lot of suggested solutions to enforce_encoding on strings but none of them seems to work. Any help would be appreciated. Thanks.