Rails 3 - Pass a parameter to custom validation method

前端 未结 2 1005
萌比男神i
萌比男神i 2021-02-10 14:12

I am looking to pass a value to a custom validation. I have done the following as a test:

validate :print_out, :parameter1 => \'Hello\'

With this

2条回答
  •  花落未央
    2021-02-10 14:24

    You could try

    validate do |object_name|
      object_name.print_out "Hello"
    end
    

    Instead of your validate :print_out, :parameter1 => 'Hello'.

提交回复
热议问题