<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tomek Urban</title>
    <description>The latest articles on DEV Community by Tomek Urban (@tomurb).</description>
    <link>https://dev.to/tomurb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F377333%2F6ef24984-f8f5-4dcd-8540-bffac4a645a2.png</url>
      <title>DEV Community: Tomek Urban</title>
      <link>https://dev.to/tomurb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tomurb"/>
    <language>en</language>
    <item>
      <title>How come your model class can call ::devise?</title>
      <dc:creator>Tomek Urban</dc:creator>
      <pubDate>Mon, 25 May 2020 21:26:08 +0000</pubDate>
      <link>https://dev.to/tomurb/how-come-your-model-class-can-call-devise-1jck</link>
      <guid>https://dev.to/tomurb/how-come-your-model-class-can-call-devise-1jck</guid>
      <description>&lt;p&gt;I've decided to read some devise code, for learning purposes. Since I'm on that mission, I'll also write some posts. The thing the internet needs is another blog that will not be read.&lt;/p&gt;

&lt;p&gt;Ok, let's get back to the question from the title.&lt;/p&gt;

&lt;p&gt;When you'll install devise in your project it will add to your User class these four lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing else changes in the class. So where the ::devise method comes from?&lt;br&gt;
&lt;a href="https://github.com/heartcombo/devise/blob/f39c6fd92774cb66f96f546d8d5e8281542b4e78/lib/devise/orm/active_record.rb"&gt;https://github.com/heartcombo/devise/blob/f39c6fd92774cb66f96f546d8d5e8281542b4e78/lib/devise/orm/active_record.rb&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ActiveSupport.on_load(:active_record) do
  extend Devise::Models
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What does ::on_load do? According to the documentation it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Declares a block that will be executed when a Rails component is fully loaded.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's all folks.&lt;/p&gt;

</description>
      <category>devise</category>
      <category>rails</category>
    </item>
  </channel>
</rss>
