Skip to content

Instantly share code, notes, and snippets.

View eltiare's full-sized avatar

Jeremy Nicoll eltiare

View GitHub Profile
/opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.6/lib/merb-core/script.rb:67:in `-': can't convert nil into Array (TypeError)
from /opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.6/lib/merb-core/script.rb:67:in `setup_local_gems'
from /opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.6/lib/merb-core/script.rb:65:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.6/lib/merb-core/script.rb:65:in `setup_local_gems'
from /opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.6/lib/merb-core/script.rb:7:in `setup_local_gems!'
from /opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.6/bin/merb:30
from /opt/local/bin/merb:19:in `load'
from /opt/local/bin/merb:19
# In DM 0.9.7 ...
class Test
include DataMapper::Resource
property :id, Integer, :serial => true
property :parent_id, Integer, :index => true
has_1 :child, :class_name => 'Test', :parent_key => [:id], :child_key => [:parent_id]
end
def destroy
sads = self_and_descendents
hooks = self.class.const_get('INSTANCE_HOOKS')
before_methods = hooks[:destroy][:before].map { |hash| hash[:name] }
after_methods = hooks[:destroy][:after].map { |hash| hash[:name] }
# Trigger all the before :destroy methods
sads.each { |sad| before_methods.each { |bf| sad.send(bf) } }
# dup is called here because destroy! likes to clear out the array, understandably.
sads.dup.destroy!
# Now go through after all the after :destroy methods.
different prefix: "/" and "."
/opt/local/lib/ruby/1.8/pathname.rb:709:in `relative_path_from'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.7/lib/merb-core/dispatch/default_exception/default_exception.rb:27:in `frame_details'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.7/lib/merb-core/dispatch/default_exception/views/index.html.erb:66:in `__opt__local__lib__ruby__gems__1_8__gems__merb__core__0_9_7__lib__merb__core__dispatch__default__exception__views__index_html_erb'
/opt/local/lib/ruby/gems/1.8/gems/erubis-2.6.2/lib/erubis/evaluator.rb:82:in `each_with_index'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.7/lib/merb-core/dispatch/default_exception/views/index.html.erb:65:in `each'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.7/lib/merb-core/dispatch/default_exception/views/index.html.erb:65:in `each_with_index'
/opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.7/lib/merb-core/dispatch/default_exception/views/index.html.erb:65:in `__opt__local__lib__ruby__gems__1_8__gems__merb__core__0_9_7__lib
class Ad
include DataMapper::Resource
property :id, Integer, :serial => true
has n, :counties, :class_name => 'Ads::Counties', :child_key => [:ad_id], :parent_key => [:id]
end
module Ads
class Counties
include DataMapper::Resource
property :id, Serial
#I'm trying to make a dynamic router in Merb based on information in the
#database. Basically, I want the user to able to build their own URL
#"tree" with the home page being at the root. If what the user wants is
#a single page in a location, getting this information is easy: all one
#has to do is store the path in the database and retrieve it. However,
#if one wants to be adding different types of functionality (such as a
#blog) to a certain part of the tree, it gets a lot trickier because you
#have the base path of the blog and then all the other paths that make
#the blog function such as:
#
class Application < Merb::Controller
override! :url
protected
def url(*args)
params[:_router].url(*args)
end
end
#This works:
drop_class.class_eval do
allowed_methods.each do |am|
define_method am do
@object.send(am)
end
end
end
Sample POST data (collected via Firebug):
housed 1
housed[address]
housed[age]
housed[arrival_date] 2009-01-15
housed[cell_phone]
housed[coming_by] Car
housed[country]
housed[custom_arrival_date]
housed[custom_arrival_date]
Request Headers:
(Request-Line) POST /houser_requests HTTP/1.1
Host localhost:4000
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive