What does :: do?

前端 未结 5 1686
南旧
南旧 2020-12-16 23:18

I have some inherited code that I am modifying. However, I am seeing something strange(to me).

I see some code like this:

::User.find_by_email(params         


        
5条回答
  •  独厮守ぢ
    2020-12-17 00:02

    It makes sure to load the User model in the global namespace.

    Imagine you have a global User model and another User model in your current module (Foo::User). By Calling ::User you make sure to get the global one.

提交回复
热议问题