When to use self in Model?

前端 未结 4 945
天涯浪人
天涯浪人 2020-12-12 19:53

Question: when do I need to use self in my models in Rails?

I have a set method in one of my models.

class SomeData < ActiveRecord::B         


        
4条回答
  •  醉酒成梦
    2020-12-12 20:11

    When use active_flag = val ruby thought your are define a local variable, the best way is self.active_flag = val, if you got it, hope you know that send(:active_flag=, val) will works too.

提交回复
热议问题