Skip to content

Instantly share code, notes, and snippets.

@caseyli
Created April 9, 2014 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caseyli/10279040 to your computer and use it in GitHub Desktop.
Save caseyli/10279040 to your computer and use it in GitHub Desktop.
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