How to simplify this Rails helper function? -
i made helper function in application_helper.rb
file:
def link_to_related(path) link_to "show", path end
so can use in forms this:
<%= link_to_related(person_path(f.object.person)) %>
is there way further simplify can say:
<%= link_to_related(:person) %>
i've been trying head around this, no avail.
thanks help.
if you're using helper link show
actions, don't need specify path, passing in object should enough:
def link_to_related(object) link_to "show", object end <%= link_to_related f.object.person %>
although that's long typing link_to "show", f.object.person
:)
Comments
Post a Comment