File_column howto (beginner)


#1

I’m trying to use file_column as a Rails plugin.
Of course I read the doc (from Sebastian, this maillist) and little
bit of source (as good as I, newbie, could understand it)…

But I’m not able to implement it in my app… I’m a totally newbie with
less software development experience.
I get the file_column_field in my view with simply invoking the
helper… (:multipart => true).

But what’s next?

  • Do I need to declare the instance methods in my model class?
  • What do I need to do with my controller, to get the process work?

Maybe somebody could provide me a little example source of model,
controller, view?
Thank you.


#2

Can I use file_column with PostgreSql?

Citeren Jonathan W. removed_email_address@domain.invalid:


#3

Bob wrote:

  • Do I need to declare the instance methods in my model class?
  • What do I need to do with my controller, to get the process work?

#Model:

class A < ActiveRecord::Base
file_column :file
end

#Controller:
@a = A.find(:first)

#View to upload file
<%= file_column_field ‘a’,‘file’ %>

#View to display file
<%= url_for_file_column ‘a’,‘file’ %>

file is the name of the model attribute that will save the filename.
So in your SQL you need:

file varchar(255) default NULL

Of course you can choose another name.

Jonathan


#4

Bob wrote:

Can I use file_column with PostgreSql?

AFAIK yes as the file is stored on the filesystem and only the filename
will be stored in the database. So you could use any of the supported
databases.

The actual file will be stored in

public/MODELNAME/ID/FILENAME

Jonathan