Skip to content

Instantly share code, notes, and snippets.

@gamov
Created September 7, 2015 08:42
Show Gist options
  • Save gamov/4e3368c17d5164dec3ce to your computer and use it in GitHub Desktop.
Save gamov/4e3368c17d5164dec3ce to your computer and use it in GitHub Desktop.
Yield in partial
# Problem: block_given always retruns true, either I call the partial with or without a block...
- if block_given?
#hidden_deletion_element= yield
- else
= link_to(deletion_path, method: :delete, confirm: 'Are you sure?', id: :hidden_deletion_element) { "Delete Me"}
@aruprakshit
Copy link

# in application helper
<% content_for? :not_authorized do %>
  <%= yield :not_authorized %>
<% end %>

# then in your view, you will call

<% content_for :not_authorized do%>
 <% your code %>
<% end %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment