Storing Support Requests from Our Mailbox
Learn to store support requests from our mailbox using the models.
As we mentioned above, the purpose of mailboxes is to allow us to execute code on every email we receive. Since emails come in whenever the sender sends them, we’ll need to store the details of a customer support request somewhere for an administrator to handle later. To that end, we’ll create a new model called SupportRequest
that will hold the relevant details of the request. We’ll also have the process()
method of SupportMailbox
create an instance for each email we get (in the final section of next lesson we’ll display these in a UI so an admin can respond).
Creating a model for support requests
We want our model to hold the sender’s email, the subject and body of the email, and a reference to the customer’s most recent order if there’s one on file. First, let’s create the model using a Rails generator:
bin/rails g model support_request
Get hands-on with 1400+ tech skills courses.