Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To require dependencies <strong>the right way in Ruby</strong> you should:</p> <ul> <li>rename <code>pagerduty.rb => pager_duty.rb</code></li> <li>require it with: <code>require 'admin/pager_duty'</code></li> </ul> <p>This is possible because Rails already adds your lib folder on your LOAD_PATH. This will work great in production for finished code (as libraries usually are).</p> <p>But if you wish to develop your lib files in development - without the need to restart server each time you make a modification, you can change your setup like that:</p> <ul> <li><p>add this line to you <code>config/application.rb</code>:</p> <p>config.autoload_paths += %W(#{config.root}/lib)</p></li> <li><p>remove any explicit require statements of lib files inside controllers or models (any app/* file)</p></li> </ul> <p>This will work good as well. <strong>But it is a common antipattern</strong>. Because:</p> <ul> <li><p>The lib code should be completely independent of your app so you can share it among applications. And if you are using the autoloading mechanism it implies it is a <em>first-class</em> citizen of your application. In this case it is much better to set up a new folder inside app (e.g. app/tools) and set up autoloading for it. Otherwise you can end up with a cluttered lib folder filled with app dependent code. More info <a href="http://blog.lunarlogic.io/2013/declutter-lib-directory/" rel="nofollow noreferrer">here</a>.</p></li> <li><p>Autoloading will not work for classes that are already defined or are defined in multiple places (e.g. monkeypatches). More info <a href="https://stackoverflow.com/questions/4235782/rails-3-library-not-loading-until-require/6797707#6797707">here</a></p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      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