0

I'm new to Ruby on Rails and I'm building a simple crm. I'm trying to convert an @lead to an @customer after they become an actual customer. In the lead show page I'd like to have a button that says convert to customer, but I'm unsure how to do this in the controller and model.

What should I do?

Thanks for the help.

1
  • If one record has to become another you need some model code that takes a Lead and converts it to a Customer. I don't see any code here, no example of what fields are being manipulated, not even a hint, so it's anyone's guess how you might do this. I normally do it with an instance method on the originating model, like @lead.to_customer returns a Customer instance you can save. Commented Sep 16, 2016 at 6:47

1 Answer 1

0

First of all, some code would be really nice. Second, your problem sounds a little bit like you need inheritance. Then you can have something like the following:

class Lead
  ... 
end

class Customer < Lead
   ... # this is your customer, having all the properties of a lead but as well new ones.
end

To transfer one lead to a customer you can then use becomes to transfer between them. From your tags I can see, that you are using Ruby on Rails, so you want to have a look at single table inheritance STI.

Hope this helps!

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Sebastian. I will give that a try. I didn't have any sample code because I haven't started the conversion process yet. But I will look into inheritance. Thanks again!
If that answers your question, feel free to accept it. Happy to help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.