Note that there are some explanatory texts on larger screens.

plurals
  1. PO"NameError, uninitialized constant" error after modifying controller code
    primarykey
    data
    text
    <p>I was able recently to organize my code by grouping everything into folders. <br> I had an issue with having the same "group name" for both my group of controllers under the <code>app/</code> directory and my module under the <code>lib/</code> directory but I was able to fix by following this: </p> <p><a href="https://stackoverflow.com/questions/18277055/rails-same-name-for-a-library-module-and-a-group-of-controllers/18277997?noredirect=1#comment26828781_18277997">Rails: Same name for a library module and a group of controllers?</a></p> <p>I also know that whenever you change your <code>lib</code> code, you need to restart the rails server which is totally fine by me. </p> <p>But after the recent re-organization, every time I change the code in the controllers, I get the following error!!!</p> <pre><code>NameError at /admin uninitialized constant Admin::PagerDuty </code></pre> <p>and to resolve it, I simply restart the server!!</p> <p>Any advice?!</p> <p>EDIT: STRUCTURE: </p> <p>Controller <code>main_controller.rb</code> is under <code>app/controllers/admin</code></p> <pre><code>class Admin::MainController &lt; ApplicationController end </code></pre> <p>Helper <code>main_helper.rb</code> is under <code>app/helpers/admin</code></p> <pre><code>module Admin::MainHelper require "admin/pager_duty.rb" def pager_duty pagerduty = Admin::PagerDuty.new() @on_call = pagerduty.on_call() @counts = pagerduty.open_incidents() end end </code></pre> <p>lib <code>pager_duty.rb</code> is under <code>lib/admin</code></p> <pre><code>module Admin class PagerDuty .... end end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload