Using #dom_id(obj) within controller to set variable
<p>I want to use the method <code>dom_id(arg)</code> within my controller.  It has always worked in my views:</p>

<pre><code># in controller
@blog = Blog.first

# then in view
&lt;%= dom_id(@blog)%&gt;
  =&gt; "blog_1"
</code></pre>

<p>However: <em>setting</em> a variable via <code>dom_id</code> does not work when doing it in the controller:</p>

<pre><code># ALL in controller
@blog = Blog.first
@dom_id_var = dom_id(@blog)
=&gt; NoMethodError: undefined method `dom_id' for main:Object
</code></pre>

<p>Is it possible to use <code>dom_id</code> within the controller?</p>

<p><a href="http://apidock.com/rails/ActionView/RecordIdentifier/dom_id" rel="noreferrer">Docs on dom_id</a></p>