:inclusion => {:in => r = (1..15), :min => r.first, :max => r.last}
This is working code I have. The thing I wanted to make dynamic is the “15” part, e.g
:inclusion => {:in => r = (1..Vehicle.max_passengers), :min => r.first, :max => r.last}
I have defined the following class method:
def self.max_passengers
15
end
Of course it didn’t work. I’ve tried using Procs and lambdas, but It didn’t work properly for me. 🙁
Can someone help me with this one – is it possible ?
You’re looking for a custom validation method:
Or, you can try the following with lambda
Note that you won’t need the min/max if you’re using
:inon range.