Skip to content

params with value was overwrite by default #51

@archfish

Description

@archfish

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions