Hi all,
I am wondering how I can simplify my life with link_to. I’ve got a lot
of pages with some of the same links and the views are getting messy.
What I’d like to do is create something like this for the Model.
def more_info_link
link = link_to “More Info”, { :action => “model_details”, :id =>
self.id}
end
def reviews_link
link = link_to “Reviews”, { :action => “model_reviews”, :id =>
self.id}
end
and then, in the view, I could just do something like this:
<%= Model.more_info_link -%> <%= Model.reviews_link -%>
So, when I try this, I get a “undefined method `link_to’ for #<Model”
error.
I’ve successfully put this in the controller helper, passing the Model
id as an arguement, but I don’t like that solution… Should I create a
new class extending UrlHelper? What is the best way to implement
something like this?
Thanks for your help…
Shagy