> On 2016-Feb-24, at 15:59 , Bee.Lists <bee.lists / gmail.com> wrote:
> 
> Hi folks.  Can someone provide some insight into how requires work with require_relative?
> 
> HQ
> изибиб Gemfile
> изибиб Gemfile.lock
> изибиб app.rb
> изибиб config.ru
> изибиб css
> ив   изибиб HQ.css
> ив   ижибиб reset.css
> изибиб img
> ив   изибиб traffic.jpg
> ив   ижибиб weather.gif
> изибиб alt
> ив   изибиб db.rb
> ив   ижибиб methods.rb
> изибиб blah.txt
> 
> In this model I would like app.rb to call methods.rb which calls db.rb when needed.  
> 
> So in app.rb:  require_relative(б╞/alt/methods.rbб╟)
> in methods.rb: require_relative(б╞db.rbб╟)
> 
> Does this work?  I was having some issues before and I forgot the specifics of them, so I thought I would ask for a best practice on the list.
> 
> Any insight appreciated.  
> 
> Cheers, Bee

Well, you want to use a relative path with require_relative, so:

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

### methods.rb
require_relative 'db'

Note that you don't typically see the .rb extension in require calls (Ruby can load .so files or the equivalent on some systems) and parentheses are rarely used for these either.

-Rob

Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>