Rails 3 - Pass a parameter to custom validation method

前端 未结 2 1790
旧巷少年郎
旧巷少年郎 2021-02-10 14:09

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:28

    You could try

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

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

提交回复
热议问题