Skip to content

Instantly share code, notes, and snippets.

View ahoward's full-sized avatar
💭
probably outside if i'm not hacking.

ara.t.howard ahoward

💭
probably outside if i'm not hacking.
View GitHub Profile
def self.find( *a, &b )
opts =
if Hash === a.last then a.last
else
a << {}
a.last
end
unless opts.has_key?(:order)
opts[:order] = 'name ASC'
# railsext.rb - my collection of rails hacks
#
# force const_missing to preload these classes - muckery
#
ActionController
ActionController::Base
ActiveRecord
ActiveRecord::Base
# railsext.rb - my collection of rails hacks
#
# force const_missing to preload these classes - muckery
#
ActionController
ActionController::Base
ActiveRecord
ActiveRecord::Base
def copy(content)
case RUBY_PLATFORM
when /darwin/
return content if `which pbcopy`.strip == ''
IO.popen('pbcopy', 'r+') { |clip| clip.puts content }
when /linux/
return content if `which xclip`.strip == ''
IO.popen('xclip', 'r+') { |clip| clip.puts content }
end
def copy(content)
case RUBY_PLATFORM
when /darwin/
return content if `which pbcopy`.strip == ''
IO.popen('pbcopy', 'r+') { |clip| clip.print content.strip }
when /linux/
return content if `which xclip`.strip == ''
IO.popen('xclip', 'r+') { |clip| clip.print content.strip}
end
has_many(:buckets, :dependent => :destroy) do
def self.extend_object buckets
super
ensure
buckets.class # hack to know about .each
buckets.each do |bucket|
bucket.collection = buckets.collection
end
end
class Bucket < ActiveRecord::Base
include Sluggable
Fu = FileUtils
belongs_to :collection
collection_reader = instance_method 'collection'
define_method('collection') do |*a|
@collection ? @collection : collection_reader.bind(self).call(*a)
end
has_many :buckets, :dependent => :destroy
buckets = instance_method(:buckets)
define_method(:buckets) do |*a|
@buckets ||= buckets.bind(self).call(*a)
@buckets.each{|bucket| bucket.collection = self}
@buckets
end
def lettuce_report_review
allows :student, :studentdemo
setup_for_student
@number = params[:id] || 1
@disabled = params[:disabled]||params[:readonly]||request.query_string.to_s[%r/disabled|readonly/]
@review = @unit.find_lettuce_report_review(:student => @student, :number => @number)
unless @review
def lettuce_report
allows :student, :studentdemo
setup_for_student
@report = @unit.find_lettuce_seed_bioassay_report(:student => @student)
@questionnaire = @report.questionnaire
@questions_and_answers = @student.questions_and_answers_for(@questionnaire, :context => @classroom, :blank => true)
if request.post?
transaction do