This request header contains the CSS selector targeted for a failed fragment update.
A fragment update is considered failed if the server responds with a status code other than 2xx, but still renders HTML.
Server-side code is free to optimize its response to a failed request by only rendering HTML that matches the provided selector. For example, you might prefer to not render an expensive sidebar if the sidebar is not targeted.
The user may choose to not send this header by configuring
X-Up-Target: .menu X-Up-Fail-Target: body
When submitting a form via AJAX
Unpoly needs to know whether the form submission has failed (to update the form with
validation errors) or succeeded (to update the
For Unpoly to be able to detect a failed form submission, the response must be return a non-2xx HTTP status code. We recommend to use either 400 (bad request) or 422 (unprocessable entity).
class UsersController < ApplicationController def create user_params = params[:user].permit(:email, :password) @user = User.new(user_params) if @user.save? sign_in @user else render 'form', status: :bad_request end end end