File_column, ActionMailer, and tests


#1

Hi,

Say I have a model Event that has a file_column called ‘pdf’.

I want to send out emails that contain the URL for the pdf file that’s
associated with the Event. I also want to test the emails, so I’d
need to be able to get at the URL for the pdf inside my unit tests.

I don’t see how I can use url_for_file_column in this situation.
Doing <%= url_for_file_column “event”, “pdf” %> in the actionmailer
doesn’t seem to work (I get a error when it tried to do
nil.relative_url_root[1]). And I also don’t see how I can use
url_for_file_column in my unit tests.

Any ideas? Am I going about this completely wrong?

Thanks,
Joe

[1]
The error occured while evaluating nil.relative_url_root

#{RAILS_ROOT}/vendor/plugins/file_column/lib/file_column_helper.rb:53:in
`url_for_file_column’
#{RAILS_ROOT}/app/views/notifier_mailer/new_registration.rhtml:19


#2

I had a similar issue but was trying to add a file to a seperate
controller/view where I was storing the file in a seperate directory
than the default filecolumn one. I also added a dynamic directory to
the mix. What I found was that file_column does not support the
only_path => false option so you have to build the url manually using
this something like this:

“#{url_for(:controller => ‘’, :only_path => false)}” + “event/” + “#
{event.id}” + “/” + “#{File.basename(event.pdf)}”

As far as using this for your tests I am not sure as i have not
figured out testing yet.

Andrew


#3

On 1/14/06, Joe Van D. removed_email_address@domain.invalid wrote:

doesn’t seem to work (I get a error when it tried to do

#{RAILS_ROOT}/vendor/plugins/file_column/lib/file_column_helper.rb:53:in
`url_for_file_column’
#{RAILS_ROOT}/app/views/notifier_mailer/new_registration.rhtml:19

Any ideas?