views:

30

answers:

1

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?

+1  A: 

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.

floatless
i just read some posts about this, telling that this no longer works in Rails 3 RC.
never_had_a_name
Yes, it's true.
floatless
they are reworking the rails 3 guides...i guess they are updating everything according to the new changes.
never_had_a_name