Skip to content

Instantly share code, notes, and snippets.

View kmelkon's full-sized avatar
👨‍💻

Karam Malkon kmelkon

👨‍💻
View GitHub Profile
@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>
@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 / 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;
});
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
$('.x').append('<%= escape_javascript(render :partial => "contacts/contact_card") %>');
$('.field-clear').val('');
$.colorbox.close();
$(".contact-card:even").addClass("pull-left");
$(".contact-card:odd").addClass("pull-right");
<div class="content pull-left">
<h2><%= @company.name %></h2>
<%= link_to "edit company", edit_company_path %>
<div class="margin-bottom">
<% for phone in @company.phone_numbers %>
<li><%= phone.number %> (<%= phone.place %>)</li>
<% end %>
</div>
<ul class="nav nav-tabs margin-top" id="company-tab">
$('.deals-wrapper').append('<%= escape_javascript(render :partial => "deals/deal") %>');
$(':input')
.not(':button, :submit')
.val('');
$(".deal:even").addClass("background-gray deal-padding");
$('.deals-wrapper').append('<%= escape_javascript(render :partial => "deals/deal") %>');
$(':input')
.not(':button, :submit')
.val('');
$(".deal:even").addClass("background-gray deal-padding");
<div class="container">
<div class="content pull-left">
<%= form_for(@deal, :url => {:action => "create"}) do |f| %>
<%= f.label :background %>
<%= f.text_area :background, :class => "input-width bottom-border" %>
<%= f.label :value %>
<%= f.text_field :value, :class => "input-width bottom-border" %>
<%= form_for [@company, @deal], :remote=> true, :id => "form" do |f| %>
<%= f.label :background %>
<%= f.text_area :background, :class => "input-width bottom-border" %>
<%= f.label :value %>
<%= f.text_field :value, :class => "input-width bottom-border" %>
<%= f.submit "Add this Deal", class: "btn submit-deals" %>
<% end %>