You don't have to match manually, there is an easier way:
protectfromforgery with: :null_session, if: Proc.new { |c| c.request.format.json? }</code></pre>
You don't have to match manually, there is an easier way: