module Unpoly::Rails
Constants
- VERSION
The current version of the unpoly-rails gem. This version number is also used for releases of the
Unpoly
frontend code.
Public Instance Methods
# File lib/unpoly/rails/change.rb, line 85 def render_nothing(options = {}) status = options.fetch(:status, :ok) self.target = ':none' controller.head(status) end
Returns the CSS selector for a fragment that Unpoly
will update in case of a successful response (200 status code).
The Unpoly
frontend will expect an HTML response containing an element that matches this selector.
Server-side code is free to optimize its successful response by only returning HTML that matches this selector.
# File lib/unpoly/rails/change.rb, line 59 def target @server_target || target_from_request end
# File lib/unpoly/rails/change.rb, line 63 def target=(new_target) @server_target = new_target end
Returns whether the given CSS selector is targeted by the current fragment update in case of a successful response (200 status code).
Note that the matching logic is very simplistic and does not actually know how your page layout is structured. It will return `true` if the tested selector and the requested CSS selector matches exactly, or if the requested selector is `body` or `html`.
Always returns `true` if the current request is not an Unpoly
fragment update.
# File lib/unpoly/rails/change.rb, line 81 def target?(tested_target) test_target(target, tested_target) end
# File lib/unpoly/rails/change.rb, line 67 def target_changed? target != target_from_request end
Returns the CSS selector for a fragment that Unpoly
will update in case of an failed response. Server errors or validation failures are all examples for a failed response (non-200 status code).
The Unpoly
frontend will expect an HTML response containing an element that matches this selector.
Server-side code is free to optimize its response by only returning HTML that matches this selector.
# File lib/unpoly/rails/change.rb, line 102 memoize def fail_target