params with value was overwrite by default
Closed this issue · 1 comments
archfish commented
Basic Info
- rails_param Version: 0.10.2
- Ruby Version: 2.3.8
- Rails Version: 4.2.11
Issue description
param! :aa, String, required: true
param! :bb, String, required: false, default: lambda { params[:aa]}
I want to set params[:bb] to params[:aa] when params[:bb] was empty, but when I set :bb in request it was overwrite by lambda { params[:aa]}
Steps to reproduce
see Issue description
code
this code set value to default not check params[name] is empty.
module RailsParam
module Param
# set default
if options[:default].respond_to?(:call)
params[name] = options[:default].call
elsif params[name].nil? && check_param_presence?(options[:default])
params[name] = options[:default]
end
end
end