Ruby on Rails Wednesday, June 28, 2017


Hello,

This is just a question, wanted to understand why are we checking values are present for request params over checking if key is present in request.

# File actionpack/lib/action_controller/metal/strong_parameters.rb, line 424  def require(key)    return key.map { |k| require(k) } if key.is_a?(Array)    value = self[key]    if value.present? || value == false      value    else      raise ParameterMissing.new(key)    end  end  


so we can have params.require(:parameter).permit(:another_parameter)?


Thanks,

Sumit M


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b5cd2e2d-3277-464f-a877-324ee0df9d98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment