Forum: Ruby on Rails file_column, ActionMailer, and tests

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.
Joe Van D. (Guest)
on 2006-01-14 17:12
(Received via mailing list)
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
<snip>
    #{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
Andrew F. (Guest)
on 2006-01-14 17:42
(Received via mailing list)
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
Joe Van D. (Guest)
on 2006-01-23 03:42
(Received via mailing list)
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
> <snip>
>     #{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?
This topic is locked and can not be replied to.