Q:

Class methods defined as instance methods

This is a working code from the Michael Hartle book. This is the mailer code in app/mailers/user_mailer.rb to create an activation mail for a user account:
class UserMailer < ActionMailer::Base
  def account_activation(user)
    @user = user
    mail to: user.email, subject: "Account activation"
  end
end

The preview of the mail is generated using the ruby file in test/mailers/previews/user_mailer_preview.rb:
class UserMailerPreview < ActionMailer::Preview
  def account_activation
    user = User.first
    user.activation_token = User.new_token
    UserMailer.account_activation(user)
  end
end

The account_activation method is defined as an instance method in user_mailer.rb. But it is used in preview generator as a class method. Did I misunderstand the code or is there something else going on here?
To anyone who have the same doubt
That's how ActionMailer works. Emails are defined as instance method in a class that extends ActionMailer::Base , but you access them as class methods.

A:

That's how ActionMailer works. Emails are defined as instance method in a class that extends ActionMailer::Base, but you access them as class methods.
class MyMailer < ActionMailer::Base
  def my_email
  end
end

MyMailer.my_email
# and not MyMailer.new.my_email

This is a shortcut that will instantiate an instance of the ActionMailer class, invoke the corresponding email method and return an email message. This is the code that handles the call.

