Skip to content

Instantly share code, notes, and snippets.

View brianjlandau's full-sized avatar

Brian Landau brianjlandau

  • Walnut Creek, CA
  • 23:47 (UTC -07:00)
View GitHub Profile
// Based on code found at: http://ejohn.org/blog/jquery-livesearch/
(function($) {
$.fn.liveUpdate = function(list, options){
var list = $(list),
original = list.html();
options = $.extend({}, options);
if ( list.length ) {
var rows = list.children('li'),
cache = rows.map(function(){
return $.trim($(this).text().toLowerCase());
module ActiveRecord
module ChangeableAttribute
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def changeable_attribute_writer(*attrbs)
attrbs.each do |attrb|
@brianjlandau
brianjlandau / optimistic_locking_form_for.rb
Created April 23, 2010 18:27
This puts the lock version of the model in the form so that Optimistic locking behaves a little more as expected.
module ActionView
module Helpers
module OptimisticLockingFormFor
def self.included(base)
base.alias_method_chain :form_for, :optimistic_locking
end
def form_for_with_optimistic_locking(record_or_name_or_array, *args, &block)
form_for_without_optimistic_locking(record_or_name_or_array, *args) do |form_with_locking|
$(document).ready(function(){
var dataChanged = false;
// record if form values ever change.
$(":input").change(function () {
dataChanged = true;
});
var $record_nav = $('select.record-nav');
if ($record_nav.length > 0){
$record_nav.each(function(){
(function($) {
$.fn.disable = function(){
return this.attr('disabled', 'disabled');
};
$.fn.enable = function(){
return this.removeAttr('disabled');
};
$.fn.findOrAppend = function(selector, html){
var results = this.find(selector);
// Example Usage:
// $('form.some-class').fieldsTabIndexFocus([
// 'input#record_name', 'textarea#record_description', 'select#some-input',
// 'fieldset#some-id li'
// ], 'input#record_name:first');
(function($) {
$.tabIndexManagers = [];
$.tabIndexManager = function(form, fields){
this.fields = fields;
simple = yes?("Should we do a simple install?")
gem 'mocha', :version => '>= 0.9.5', :env => 'test'
gem 'factory_girl', :lib => 'factory_girl', :source => 'http://gemcutter.org', :version => '>= 1.2.0', :env => 'test'
gem 'shoulda', :lib => 'shoulda/rails', :source => 'http://gemcutter.org', :env => 'test'
gem 'authlogic'
gem "formtastic", :source => 'http://gemcutter.org'
gem 'validation_reflection'
unless simple
gem "matthuhiggins-foreigner", :lib => "foreigner"
end
diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb
index bb9e1dc..68a898d 100644
--- a/app/controllers/invitations_controller.rb
+++ b/app/controllers/invitations_controller.rb
@@ -1,20 +1,16 @@
class InvitationsController < ApplicationController
+ before_filter :require_analyst
+
def new
@invitation = Invitation.new
@brianjlandau
brianjlandau / en.yml
Created January 24, 2010 20:43
A Time Duration object that is meant to primarily be used inside a Rails app (as it requires i18n and ActiveSupport). It aslo uses chronic_duration to parse a time period/duration word phrase..
en:
datetime:
distance_in_words:
x_weeks:
one: '1 week'
other: "{{count}} weeks"
x_hours:
one: "1 hour"
other: "{{count}} hours"
x_years:
class ActiveSupport::TestCase
protected
# Use this to destroy ActiveRecord models you created and stored in instance variables.
# Pass in the names of the instance variables:
#
# teardown do
# destroy_and_nil(*%w(contact_details user product))
# end