Uploading a file in Rails

[code type=html]
<%= form_for @person do |f| %>
<%= f.file_field :picture %>
<% end %>

[code type=ruby]
uploaded_io = params[:person][:picture]
File.open(Rails.root.join(‘public’, ‘uploads’, uploaded_io.original_filename), ‘wb’) do |file|
file.write(uploaded_io.read)
end

Referência

Share and Enjoy !

0Shares
0 0 0