Skip to content

Instantly share code, notes, and snippets.

View aeden's full-sized avatar

Anthony Eden aeden

View GitHub Profile
connectAddForm: function() {
$("form.people").submit(function() {
$.ajax({
type: 'post',
dataType: 'json',
url: '/people',
data: $(this).serialize(),
success: function(json) {
$('ul.people').append('<li><span class="name">' + json.person.name + '</span> <a href="/people/' + json.person.id + '/delete" class="delete">delete</a></li>');
$('#person_name').val('');
$(document).ready(function(){
Actions.connectAddForm();
Actions.connectDeleteLinks();
});
<% form_tag(person_url(@person)) do %>
<%= hidden_field_tag :_method, 'delete' %>
<p>Are you sure you want to delete <%= @person.name %>?</p>
<%= submit_tag 'Delete' %>
<%= link_to 'Cancel', people_url %>
<% end %>
<ul class="people">
<li style="display:none"></li>
<% @people.each do |person| -%>
<li><span class="name"><%= person.name %></span> <%= link_to 'delete', delete_person_path(person), :class => 'delete' %></li>
<% end -%>
</ul>
<% form_for :person, :url => people_url, :html => {:class => 'people'} do |f| -%>
<%= f.text_field :name %> <%= f.submit 'Add Person'%>
<% end -%>
class PeopleController < ApplicationController
def index
@people = Person.all
end
def create
@person = Person.new(params[:person])
@person.save!
respond_to do |format|
format.html { redirect_to people_url }
@aeden
aeden / evil.rb
Created January 19, 2010 06:32 — forked from will/evil.rb
# worst thing you can do to someone in ruby?
# fork this and add other evil
class Module
def method_added(method)
undef_method method if rand > 0.999999
end
end
# Fun with forking
aeden:~$ rvm remove macruby-head; rvm install macruby-head --trace
it seems that /Users/aeden/.rvm/src/macruby-head is already non existent.
it seems that /Users/aeden/.rvm/macruby-head is already non existent.
install macruby-head --trace
+ [[ -z install ]]
+ [[ ! -z '' ]]
@aeden
aeden / gist:220808
Created October 28, 2009 20:41 — forked from kmayer/gist:220166
while true do
RefineryQueue.stats_update
sleep 60
end
Checkout:
git clone url
Checkout throwing away local changes:
git checkout -f
Checkout a single file to get it back to HEAD:
module Autotest::CustomTestMatch
Autotest.add_hook :initialize do |at|
at.add_mapping(/test/) do |f, _|
at.files_matching(/_test\.rb$/)
end
at.add_mapping(/lib\/.*/) do |f, _|
at.files_matching(/_test\.rb$/)
end
at.add_exception('test/performance')
end