[英]Converting Instance Variables in Ruby on Rails
I'm new to Ruby on Rails and I'm building a simple crm. 我是Ruby on Rails的新手,并且正在构建一个简单的crm。 I'm trying to convert an @lead to an @customer after they become an actual customer.
在他们成为实际客户之后,我正尝试将@lead转换为@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. 谢谢您的帮助。
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. 要将一条
lead
customer
转移给customer
您可以使用变得在他们之间转移。 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 . 从您的标签中可以看到,您正在使用Ruby on Rails,因此您希望了解单表继承STI 。
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.