The problem I am having, is when I try to create a new ticket, I get the error:
NoMethodError (undefined method `customer' for nil:NilClass): app/models/ticket_mailer.rb:7:in `newticket' app/controllers/tickets_controller.rb:84:in `create'
Which I know simply put is telling me the customer doesn't exist, because customer_id would be nil, so there is no association. But there is.
No, it's telling you that the "ticket" variable (at line 7 of ticket_mailer.rb) is nil, and NilClass objects don't have a "customer" method.
class TicketMailer < ActionMailer::Base def newticket(ticket) ticket = @ticket subject 'A new ticket has been created for you' recipients ticket.customer.email from 'helpdesk@stevenshenager.edu' sent_on Time.now end
I'd assume the problem is caused by the assignment in the first line of the method; I'd guess it's meant to read: @ticket = ticket ..because as it is, it doesn't make much sense to pass in a ticket parameter and then immediately overwrite it with an instance variable.