Pass the current controller to the model

I have no idea what you’re saying… but if you need to pass things to the model, make an attribute accessor in the model.

class MyModel < ActiveRecord::Base

attr_accessor :some_var

end

Then you can do

my_model = MyModel.new
my_model.some_var = “test”

my_model.some_var
(should return “test”

That’s how I pass lots of things to my models. Either that, or make a whole method in the model that does what you want and have it take parameters.

You might actually want to look at the attachment_fu or file_column plugins. They do what you want to do.

I understand that… what I meant is look at their source code and see how they handle this. file_column has /public/model_name as the default file location, and the model handles the actual receiving and writing of the file to the right location. Check it out.