Topic: how to assign object to User when Order is placed
I have Orders has_many Line_Items => belongs_to Lead
I have Users (devise) and a HABTM model for Users_leads with the right fields in the table.
I want to create a relationship between the User checking out and the Lead being purchased. I have a after_save method setup in the Order model for this purpose. I just don't know how to write the method:
def assign_lead_to_user self.line_item.lead.users_leads #NEEDs TO CREATE THE RELATIONSHIP BETWEEN EACH LEAD being purchased and the Current User save! end
This will later be used to reference current_user.leads.each do |lead| in the customers account.
Seattle Website Development