title: Accessing view_context in Model
body: <p>Within a model I have the following method:</p>
  
  <pre><code>def some_method
    some_obj.new(view_c: view_context).create_some_links
  end
  </code></pre>
  
  <p>An exception is thrown with the following message:</p>
  
  <blockquote>
    <p>undefined local variable or method `view_context' </p>
  </blockquote>
  
  <p>I am fully aware that it is not good practice to call view-related methods from your model, but nonetheless: Is it possible to access <code>view_context</code> from the model so that I can pass it along to a Plain Old Ruby Object (PORO) which creates some links?</p>
  
  <p><strong>Update</strong>: From the code I have above, one suggestion might be to simply create and call the PORO directly in the view.  However: pretend that the code requires it to go through the model in order to create the right PORO.</p>
  
  <p><a href="https://apidock.com/rails/AbstractController/Rendering/view_context" rel="nofollow noreferrer">view_context doc</a></p>