I hereby claim:
- I am boone on github.
- I am boone (https://keybase.io/boone) on keybase.
- I have a public key whose fingerprint is 7713 6FEA DE34 477B 241F E9EB 9D8A 85BC B79C C67E
To claim this, I am signing this object:
class Project < ActiveRecord::Base | |
has_many :tasks | |
accepts_nested_attributes_for :tasks, :reject_if => :all_blank, :allow_destroy => true | |
def validate | |
# require a minimum of one task | |
undestroyed_task_count = 0 | |
tasks.each { |t| undestroyed_task_count += 1 unless t.marked_for_destruction? } |
# monkey patch to allow authlogic's *_credentials cookies set the HttpOnly bit | |
# put this file in config/initializers/authlogic.rb and set the value after | |
# instantiating your session model, e.g. | |
# @user_session = UserSession.new(params[:user_session]) | |
# @user_session.httponly = true | |
module Authlogic | |
module Session | |
module Cookies | |
module Config |
# file_column Shoulda macro, based off the Paperclip method given here: | |
# http://giantrobots.thoughtbot.com/2008/3/18/for-attaching-files-use-paperclip#comment--614050918 | |
# pass the extra option :magick => true to test the extra method for the columns that use RMagick | |
def self.should_have_file_column(attachment, options = {}) | |
klass = described_type | |
fields = ["#{attachment}", "#{attachment}=", "#{attachment}_temp", "#{attachment}_temp=", | |
"#{attachment}_dir", "#{attachment}_just_uploaded?", "#{attachment}_options", | |
"#{attachment}_relative_dir", "#{attachment}_relative_path"] | |
fields << "#{attachment}_magick_after_assign" if options[:magick] | |
should "have_file_column #{attachment}" do |
# original slow method to find a number plus a divider (|) | |
# at the start of a line | |
def find_num(file, num) | |
found = false | |
File.read(file).each do |line| | |
if line.chomp.split('|', -1)[0] == num | |
found = true | |
break | |
end | |
end |
# truncate string by byte limit | |
# | |
# str - String | |
# limit - Maximum number of bytes | |
# | |
# Returns a String | |
def limit_string(str, limit) | |
limited_string = "" | |
str.each_char do |c| |
I hereby claim:
To claim this, I am signing this object: