This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class List < ActiveRecord::Base | |
attr_accessible :name, :items_to_add | |
has_many :items | |
# Allows me to easily build forms that do | |
# complex things but still plug into | |
# mass-assignment. | |
def items_to_add=(items) | |
items.each{|i| add_item(i)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sqlite3' | |
require 'debugger' | |
DB = SQLite3::Database.new("studentbody.db") | |
create_students_table_sql = <<SQL | |
CREATE TABLE students | |
( | |
id INTEGER PRIMARY KEY, | |
first_name TEXT, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calls function on $ if it is an existing piece of dom. | |
// $('foo.bar').exists(function(){$("#target").show();}) -> foo.bar will appear where foo.bar is present | |
// $('foo.baz').exists(function(){$("#target").show();}) -> foo.baz will not appear where foo.baz is not present | |
jQuery.fn.exists = function(func){if (this[0]) {if (func){func.apply(this, arguments);} else {return true;}} else {if (func){return this;} else {return false;}};}; |