On 25 February 2016 at 06:59, Bee.Lists <bee.lists / gmail.com> wrote:

> Hi folks.  Can someone provide some insight into how requires work with
> require_relative?
>
>
There's always the documentation
<http://ruby-doc.org/core-2.3.0/Kernel.html#method-i-require_relative>:

---
   Ruby tries to load the library named *string* *relative to the requiring
file”Ēs path*. If the file”Ēs path cannot be determined a LoadError is
raised. If a file is loaded true is returned and false otherwise.
---
(my emphasis)

So you'd have this:

~~~ app.rb
require_relative 'alt/methods'
~~~

~~~ alt/methods.rb
require_relative 'db'
~~~

As Rob said in his reply, you don't need (and shouldn't include) the ".rb"
on the end of the required target. Think of it as *requiring a library*,
not *loading a file*. (Side note: if you do want to load a file, there's
Kernel#load <http://ruby-doc.org/core-2.3.0/Kernel.html#method-i-load>)

Cheers
-- 
  Matthew Kerwin
  http://matthew.kerwin.net.au/
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>