{"id":1125,"date":"2022-08-30T15:12:48","date_gmt":"2022-08-30T15:12:48","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/ruby-on-rails-use-variable-in-association-call-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:12:48","modified_gmt":"2022-08-30T15:12:48","slug":"ruby-on-rails-use-variable-in-association-call-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/ruby-on-rails-use-variable-in-association-call-collection-of-common-programming-errors\/","title":{"rendered":"ruby on rails use variable in association call-Collection of common programming errors"},"content":{"rendered":"<p>Here is the same answer as ~AmirRubin, but fleshed out more.<\/p>\n<p>I am assuming that friend was the object, method was the helper, .profile is the method you want the helper to use.<\/p>\n<p>Define your helper as:<\/p>\n<pre><code>def call_method(object, method_name)\n  object.send(method_name)\nend\n<\/code><\/pre>\n<p>In your view call it as:<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>Adjust this if my assumptions are wrong. If you need to send the method name (symbol) to the partial pass it in the locals.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:30:43. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Here is the same answer as ~AmirRubin, but fleshed out more. I am assuming that friend was the object, method was the helper, .profile is the method you want the helper to use. Define your helper as: def call_method(object, method_name) object.send(method_name) end In your view call it as: Adjust this if my assumptions are wrong. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1125","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1125"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1125\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}