title: Rails 4 strong parameters without required parameters
body: <p>I'm using Rails 4 and I don't know what is the best way to use strong parameters without required parameters. So, that's what I did:</p>
  
  <pre><code>def create
  device = Device.new(device_params)
  .................
  end
  
  private
  
  def device_params
    if params[:device]
      params.require(:device).permit(:notification_token)
    else
      {}
    end
  end
  </code></pre>
  
  <p>My device model does not validate presence of anything.
  I know I could do something like that too:</p>
  
  <pre><code>device = Device.new
  device.notification_token = params[:device][:notification_token] if params[:device] &amp;&amp; params[:device][:notification_token]
  </code></pre>
  
  <p>Is there any conventions or the right way to do that?</p>