Implicit argument passing of super from method defined by define_method() is not supported

前端 未结 2 543
一个人的身影
一个人的身影 2021-02-07 12:38

In \"Agile Web Development with Rails\" (third edition) page 537 - 541 it has \"Custom Form Builders\" code as follows:

  class TaggedBuilder < Actio         


        
相关标签:
2条回答
  • 2021-02-07 13:01

    I encountered with this problem in a define_method without arguments

    define_method :"#{info_type}_info" do
    
      info = super
      .......
    
    end
    

    And still found this problem. I had to explicit put the parenthesis:

    define_method :"#{info_type}_info" do
    
      info = super()
      .......
    
    end
    
    0 讨论(0)
  • 2021-02-07 13:12

    The super above passed all parameters (see this recent question).

    As the error message states, you must here "specify all arguments explicitly". Replace super with super(label, *args).

    0 讨论(0)
提交回复
热议问题