What does #self.included(base) do in Ruby on Rails' Restful Authentication?

后端 未结 5 1933
离开以前
离开以前 2021-01-30 03:50

I thought we would do

helper_method :current_user, :logged_in?, :authorized?

to make these controller methods available for use as helper metho

5条回答
  •  生来不讨喜
    2021-01-30 04:32

    The self.included function is called when the module is included. It allows methods to be executed in the context of the base (where the module is included).

    More info: a ruby mixin tutorial.

提交回复
热议问题