Skip to content

Instantly share code, notes, and snippets.

@AnithaPal
Last active March 6, 2017 15:56
Show Gist options
  • Save AnithaPal/b2aa2eaeea1adace3df4ba1b6b3eb0c9 to your computer and use it in GitHub Desktop.
Save AnithaPal/b2aa2eaeea1adace3df4ba1b6b3eb0c9 to your computer and use it in GitHub Desktop.
- content_for :item_title do
= link_to unit.name, unit
= content_for :actions do
= edit_button(unit)
= destroy_button(unit)
= link_to replicate_unit_path(unit), remote: true, class: 'btn btn-default replicate-unit' do
%i.fa.fa-copy
= label_group 'Issues' do
- if unit.alerts?
.tag.tag-danger
%i.fa.fa-exclamation-triangle
= unit.alerts.count
- else
.tag.tag-success
%i.fa.fa-check
0
<% if @unit_replica.valid? %>
$('ul').append("<%= j render 'unit', locals: {unit: @unit_replica} %>");
<% end %>
$(function(){
$("link").click(function(event){
$.ajax({
type:'get',
url: "replicate.js"
});
});
});
def replicate
authorize @unit
@unit_replica = @unit.replicate_unit
authorize @unit_replica
# redirect_to account_units_path
respond_to do |format|
format.html { redirect_to referer, notice: 'Unit copied' }
# format.js {}
format.js
end
# render nothing: true, status: 200, content_type: 'text/html'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment