Skip to content

Instantly share code, notes, and snippets.

View kmelkon's full-sized avatar
👨‍💻

Karam Malkon kmelkon

👨‍💻
View GitHub Profile
@kmelkon
kmelkon / application.js
Created July 23, 2013 12:15
application.js
$(function(){
$('.delete_post').bind('ajax:success', function() {
$(this).closest('tr').fadeOut();
});
$("#form").submit(function() {
$post($(this).attr("action") + '.js', $(this).serialize(), null, "script");
return false;
});
@kmelkon
kmelkon / _show.htm.erb
Created July 23, 2013 12:14
show partial
<% @posts.each do |post| %>
<tr>
<td><%= post.name %></td>
<td><%= post.title %></td>
<td><%= post.content %></td>
<td><%= link_to 'Show', post %></td>
<td><%= link_to 'Edit', edit_post_path(post) %></td>
<td><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' }, :remote => true, :class => 'delete_post' %></td>
@kmelkon
kmelkon / gist:6061906
Created July 23, 2013 12:12
index view
<h1>Listing posts</h1>
<table>
<tr>
<th>Name</th>
<th>Title</th>
<th>Content</th>
<th></th>
<th></th>
<th></th>