never_had_a_name
never_had_a_name

Reputation: 93146

Load path in Rails?

In the Rails guides they have this code to load a path.

  $LOAD_PATH << path
  ActiveSupport::Dependencies.load_paths << path
  ActiveSupport::Dependencies.load_once_paths.delete(path)

The first one I understand. That is for ruby to know where to require files.

But what does the second and the third one means?

Upvotes: 1

Views: 1581

Answers (2)

Jack Kinsella
Jack Kinsella

Reputation: 4631

In Rails 3.0 load_once_paths has been renamed to autoload_once_paths and load_paths has been renamed to autoload_once_paths.

Upvotes: 0

Daniel O&#39;Hara
Daniel O&#39;Hara

Reputation: 13438

Yes, the first line is for Ruby itself (and $: too). The second one is very similar to the first one, but for ActiveSupport.

load_once_paths An array of paths from which Rails will automatically load from only once. All elements of this array must also be in load_paths.

load_paths An array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list.

So, if you need to reload your dependencies every new request, don't add them to the one of load_once_paths directory.

Upvotes: 2

Related Questions