Forum: Ruby on Rails Uploading files

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Emil K. (Guest)
on 2007-01-16 14:40
Hi there.

Is there anyone, who can direct me to a site, that explains how to
upload a file via RoR

Im a beginner
harper (Guest)
on 2007-01-16 15:05
Emil K. wrote:
> Hi there.
>
> Is there anyone, who can direct me to a site, that explains how to
> upload a file via RoR
>
> Im a beginner

look up file_column:

http://www.kanthak.net/opensource/file_column/

i think there are other things out there (in fact, maybe even better)
but i think this quite basic and good enough.
hth,

s
harper (Guest)
on 2007-01-16 15:06
((ignore the Rmagik stuff in the meantime))
Nick S. (Guest)
on 2007-01-16 15:10
Other options are:

acts_as_attachment:
http://technoweenie.stikipad.com/plugins/show/Acts...

or

flex_image: http://beautifulpixel.textdriven.com/

Kind regards,

Nick S.
--
http://railshostinginfo.com
Compare and review Rails hosting
Nicolas B. (Guest)
on 2007-01-16 15:15
You can also put this kind of stuff in your controller (for example) or
for DRY put it in your model...

    @file = params[:image][:img]
    if @file.original_filename.length > 0
      filename = session[:dirname] + "/" + @file.original_filename
      File.open(filename, "w")  { |f| f.write(@file.read) }
    end
    redirect_to :action => "index"


Emil K. wrote:
> Hi there.
>
> Is there anyone, who can direct me to a site, that explains how to
> upload a file via RoR
>
> Im a beginner
Emil K. (Guest)
on 2007-01-16 16:58
Nicolas B. wrote:
> You can also put this kind of stuff in your controller (for example) or
> for DRY put it in your model...
>
>     @file = params[:image][:img]
>     if @file.original_filename.length > 0
>       filename = session[:dirname] + "/" + @file.original_filename
>       File.open(filename, "w")  { |f| f.write(@file.read) }
>     end
>     redirect_to :action => "index"
>
>

DRY ?? What is this ?

 - Emil
Rick O. (Guest)
on 2007-01-16 17:46
(Received via mailing list)
On 1/16/07, Emil K. <removed_email_address@domain.invalid> wrote:
> >     redirect_to :action => "index"
> >
> >
>
> DRY ?? What is this ?

DRY means Don't Repeat Yourself, a common mantra for rails developers.
 For instance, using one of the above mentioned plugins means this
will probably be taken care of for you.

If you're on rails 1.2 and were looking at acts_as_attachment, I'd
suggest my refactored update attachment_fu.  It has an #uploaded_data
accessor that handles the above code in your model.

--
Rick O.
http://weblog.techno-weenie.net
http://mephistoblog.com
This topic is locked and can not be replied to.