Hi there,

I am trying to get something working and its driving me crazy. I have 
been looking around for solutions to getting view helpers working in 
models and for the most part I find this solution.

Add the following in the model you want to use them in

  include ActionView::Helpers::UrlHelper
  include ActionController::UrlWriter

However, when I try something like

link_to(polymorphic_path(@node)) I get an error.

"can't convert String into Hash"

This is because 'link_to' uses 'url_for' which is a method that both UrlHelper 
and UrlWriter both have which actually behave differently.

so my polymorphic_path(@node) => "/nodes/1" is a string and ActionController's 
url_for is expecting a hash.

Has anyone seem this and found a nice clean solution, or is this just the wrong 
way to go about things

Cheers

RobL
http://www.robl.me




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to