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.
525e0c75f4f5c1d0ab0b6cc91575b74f?d=identicon&s=25 Emil Kampp (emuen)
on 2007-01-16 13: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
Ce953bec3af375ddc75e375233112b28?d=identicon&s=25 harper (Guest)
on 2007-01-16 14:05
Emil Kampp 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
Ce953bec3af375ddc75e375233112b28?d=identicon&s=25 harper (Guest)
on 2007-01-16 14:06
((ignore the Rmagik stuff in the meantime))
91308e9bc88cb069fd1bcf88e910d042?d=identicon&s=25 Nick Snels (nicksnels)
on 2007-01-16 14:10
Other options are:

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

or

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

Kind regards,

Nick Snels
--
http://railshostinginfo.com
Compare and review Rails hosting
8458ed8e78b2660f8b839f052e20f65f?d=identicon&s=25 Nicolas Blanco (slainer68)
on 2007-01-16 14: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 Kampp 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
525e0c75f4f5c1d0ab0b6cc91575b74f?d=identicon&s=25 Emil Kampp (emuen)
on 2007-01-16 15:58
Nicolas Blanco 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
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2007-01-16 16:46
(Received via mailing list)
On 1/16/07, Emil Kampp <rails-mailing-list@andreas-s.net> 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 Olson
http://weblog.techno-weenie.net
http://mephistoblog.com
This topic is locked and can not be replied to.