views:

393

answers:

1

I have a paperclip interpolation that I want to use one of my view helpers for. I have the route set up so I can use

foo_bar_photo_path

so I just want to use that in the interpolation as well.

Paperclip::Attachment.interpolations[:mykey] = lambda do |a,s
  foo_bar_photo_path(something,something)
end

Unfortunately, it whines with undefined method.

How can I get access to this method, or is there a better way of doing this?

+1  A: 

Try this (you didnt include the urlwriter module in your model):

http://paulsturgess.co.uk/articles/show/67-using-routes-in-models-in-ruby-on-rails

But be informed (like the first comment on the link says):

And there goes proper MVC encapsulation flying out of the window…

Lichtamberg
Yeah, and I suppose that's the problem, but at the same time, how do I accomplish what I want, without either doing this, or coding things by hand and then having to remember to update when the route changes...
Daniel Huckstep