Forum: Ruby on Rails upload an image

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dcf093a36c8a7e286dbefe10454813e1?d=identicon&s=25 Ishara Gunathilake (Guest)
on 2008-11-05 14:03
(Received via mailing list)
can anyone give me the code for upload an image,,i try
in various ways such as acts_as_attatchment plugin but
it wasn't im in a big trouble,,,plz give me another
solution to this
2d8132658d56e51f19ace1c68e48b6aa?d=identicon&s=25 Thorsten Mueller (thorsten)
on 2008-11-05 14:20
(Received via mailing list)
the view:

  <% form_for(@user, :url => (@edition ? user_path() :
user_path), :method => :put, :html => {:multipart => true}) do |f| %>
    <%= f.file_field(:user_image_file) %><br />
    <%= submit_tag('Save') %>
  <% end %>

in the controller:

    if params[:user][:user_image_file] then

the model:

  def upload_image
    if user_image_file && user_image_file != "" then
      file = user_image_file
MIME::Types.type_for(file.original_filename).to_s.gsub('image/', '')),
image_filename(:original)), 'wb') { |f| f.write( }

This topic is locked and can not be replied to.