Skip to content

Autoload models and permits

kristianmandrup edited this page Nov 8, 2011 · 2 revisions

Cantango is by default setup to autoload the following:

  • Models (app/models)
  • Permits (app/permits)

The autoloading is performed as part of the Cantango Rails engine initialization.

To configure autoloading:

Cantango.configure.autoload do |load|
  load.models :off
  load.permits :on
end

Models autoloading

Models are autoloaded in order to be sure that the Cantango class macros such as #tango_user are executed and thus that User and Account models are registered with Cantango.

If you don't wont to autoload the models for performance or other reasons, you can alternatively register the User and Account models directly (see Configuration).

CanTango.config.users.register :admin, AdminUser

Permits autoloading

Permits autoloading is done to ensure that the Permits are made available to CanTango::Ability. If you want full control over which Permits are loaded when, you can disable this feature and register the Permits manually as described in Configuration.

CanTango.config.permits.register_class AdminUserPermit