Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rest In Place Helper that takes Authorization into account
module ApplicationHelper
# This helper will basically create a rest-in-place spans around your content, but will prevent it from being active if editable is false
def rest_in_place(text, attribute, editable)
css_class = "rest-in-place" if editable
content_tag(:span, data: { attribute: attribute }, class: css_class) do
text
end
end
end
<div data-object="product">
<%= rest_in_place product.name, "name", is_admin? %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment