Internal server error 500
undefined method `key' for #
/Users/wieck/Projects/nytmedia/trunk/lib/dm/lib/data_mapper/associations/has_and_belongs_to_many_association.rb in "method_missing" 265
260 results << (val.is_a?(Enumerable) ? val.entries : val) 261 end 262 end 263 results.flatten 264 else 265 super 266 end 267 end 268 269 def entries 270 @entries || @entries = begin
/Users/wieck/Projects/nytmedia/trunk/lib/dm/lib/data_mapper/associations/has_and_belongs_to_many_association.rb in "save_without_validation" 197
192 keys = [] 193 194 @entries.each do |member| 195 adapter.save_without_validation(database_context, member) 196 values << "(?, ?)" 197 keys << @instance.key << member.key 198 end 199 200 adapter.connection do |db| 201 command = db.create_command(sql << ' ' << values.join(', ')) 202 command.execute_non_query(*keys)
/Users/wieck/Projects/nytmedia/trunk/lib/dm/lib/data_mapper/associations/has_and_belongs_to_many_association.rb in "each" 194
189 if adapter.batch_insertable? 190 sql = association.to_insert_sql 191 values = [] 192 keys = [] 193 194 @entries.each do |member| 195 adapter.save_without_validation(database_context, member) 196 values << "(?, ?)" 197 keys << @instance.key << member.key 198 end 199
/Users/wieck/Projects/nytmedia/trunk/lib/dm/lib/data_mapper/associations/has_and_belongs_to_many_association.rb in "save_without_validation" 194
189 if adapter.batch_insertable? 190 sql = association.to_insert_sql 191 values = [] 192 keys = [] 193 194 @entries.each do |member| 195 adapter.save_without_validation(database_context, member) 196 values << "(?, ?)" 197 keys << @instance.key << member.key 198 end 199
/Users/wieck/Projects/nytmedia/trunk/lib/dm/lib/data_mapper/adapters/data_object_adapter.rb in "save" 217
212 instance.attributes.each_pair do |name, value| 213 instance.original_values[name] = value 214 end 215 216 instance.loaded_associations.each do |association| 217 association.save_without_validation(database_context) if association.dirty? 218 end 219 220 callback(instance, :after_save) 221 result 222 end
/Users/wieck/Projects/nytmedia/trunk/lib/dm/lib/data_mapper/adapters/data_object_adapter.rb in "each" 216
211 instance.database_context = database_context 212 instance.attributes.each_pair do |name, value| 213 instance.original_values[name] = value 214 end 215 216 instance.loaded_associations.each do |association| 217 association.save_without_validation(database_context) if association.dirty? 218 end 219 220 callback(instance, :after_save) 221 result
/Users/wieck/Projects/nytmedia/trunk/lib/dm/lib/data_mapper/adapters/data_object_adapter.rb in "save" 216
211 instance.database_context = database_context 212 instance.attributes.each_pair do |name, value| 213 instance.original_values[name] = value 214 end 215 216 instance.loaded_associations.each do |association| 217 association.save_without_validation(database_context) if association.dirty? 218 end 219 220 callback(instance, :after_save) 221 result
/Users/wieck/Projects/nytmedia/trunk/lib/dm/lib/data_mapper/context.rb in "save" 60
55 def count(klass, *args) 56 table(klass).count(*args) 57 end 58 59 def save(instance) 60 @adapter.save(self, instance) 61 end 62 63 def destroy(instance) 64 @adapter.delete(self, instance) 65 end
/Users/wieck/Projects/nytmedia/trunk/lib/dm/lib/data_mapper/support/active_record_impersonation.rb in "save" 11
6 def self.included(base) 7 base.extend(ClassMethods) 8 end 9 10 def save 11 database_context.save(self) 12 end 13 14 def reload! 15 database_context.first(self.class, key, :select => original_values.keys, :reload =>...... 16 self.loaded_associations.each { |association| association.reload! }
models/user.rb in "assign_role" 111
106 return true if roles.include?(role) 107 # self.class.transcation do 108 permissions << role.permissions 109 permission = permissions.uniq 110 111 self.save 112 return true if roles << role 113 # end 114 end 115 116 def purchase_items(array)
controllers/users.rb in "add_role" 131
126 127 def add_role 128 @user = User[params[:id]] 129 @role = Role[params[:role_id]] 130 131 record(RoleAssignment, @role ) if @user.assign_role(@role) 132 133 session[:notice] = "#{@user.login} now has #{@role.name} permissions" 134 135 redirect url(:edit_user, @user) 136 end
controllers/application.rb in "send" 19
14 def self.parameters_for_action(action) 15 @parameters_for_action[action] 16 end 17 18 def call_action(action) 19 send(action, *self.class::parameters_for_action(action).map { |name| params[name] }) 20 end 21 22 def self.dispatch(*args) 23 database do # wrapping the entirety of everything in ONE db context 24 super
controllers/application.rb in "call_action" 19
14 def self.parameters_for_action(action) 15 @parameters_for_action[action] 16 end 17 18 def call_action(action) 19 send(action, *self.class::parameters_for_action(action).map { |name| params[name] }) 20 end 21 22 def self.dispatch(*args) 23 database do # wrapping the entirety of everything in ONE db context 24 super
/Users/wieck/Projects/nytmedia/trunk/framework/merb/abstract_controller.rb in "dispatch" 42
37 result 38 end 39 40 @_body = case caught 41 when :filter_chain_completed 42 call_action(action) 43 when String 44 caught 45 when nil 46 filters_halted 47 when Symbol
/Users/wieck/Projects/nytmedia/trunk/framework/merb/controller.rb in "dispatch" 80
75 def dispatch(action=:index) 76 start = Time.now 77 if self.class.callable_actions[action.to_s] 78 params[:action] ||= action 79 setup_session 80 super(action) 81 finalize_session 82 else 83 raise ActionNotFound, "Action '#{action}' was not found in #{self.class}" 84 end 85 @_benchmarks[:action_time] = Time.now - start
/Users/wieck/Projects/nytmedia/trunk/framework/merb/dispatcher.rb in "dispatch_action" 51
46 # build controller 47 controller = klass.build(request, response, status) 48 # complete setup benchmarking 49 #controller._benchmarks[:setup_time] = Time.now - start 50 if @@use_mutex 51 @@mutex.synchronize { controller.dispatch(action) } 52 else 53 controller.dispatch(action) 54 end 55 [controller, action] 56 end
/Users/wieck/Projects/nytmedia/trunk/framework/merb/dispatcher.rb in "synchronize" 51
46 # build controller 47 controller = klass.build(request, response, status) 48 # complete setup benchmarking 49 #controller._benchmarks[:setup_time] = Time.now - start 50 if @@use_mutex 51 @@mutex.synchronize { controller.dispatch(action) } 52 else 53 controller.dispatch(action) 54 end 55 [controller, action] 56 end
/Users/wieck/Projects/nytmedia/trunk/framework/merb/dispatcher.rb in "dispatch_action" 51
46 # build controller 47 controller = klass.build(request, response, status) 48 # complete setup benchmarking 49 #controller._benchmarks[:setup_time] = Time.now - start 50 if @@use_mutex 51 @@mutex.synchronize { controller.dispatch(action) } 52 else 53 controller.dispatch(action) 54 end 55 [controller, action] 56 end
/Users/wieck/Projects/nytmedia/trunk/framework/merb/dispatcher.rb in "handle" 35
30 raise ControllerExceptions::NotFound, "Route matched, but route did not specify a...... 31 end 32 MERB_LOGGER.debug("Routed to: #{request.route_params.inspect}") 33 # set controller class and the action to call 34 klass = request.controller_class 35 dispatch_action(klass, request.action, request, response) 36 rescue => exception 37 MERB_LOGGER.error(Merb.exception(exception)) 38 exception = controller_exception(exception) 39 dispatch_exception(request, response, exception) 40 end
/Users/wieck/Projects/nytmedia/trunk/framework/merb/mongrel_handler.rb in "process" 86
81 MERB_LOGGER.info("Serving static file: #{page_cached}") 82 request.params[Mongrel::Const::PATH_INFO] = page_cached 83 @files.process(request,response) 84 else 85 # Let Merb:Dispatcher find the route and call the filter chain and action 86 controller, action = Merb::Dispatcher.handle(request, response) 87 benchmarks.merge!(controller._benchmarks) 88 benchmarks[:controller] = controller.class.to_s 89 benchmarks[:action] = action 90 91 MERB_LOGGER.info("Routing to controller: #{controller.class} action: #{action}\nRoute......
mongrel-1.0.1/lib/mongrel.rb in "process_client" 618
613 # request is good so far, continue processing the response 614 response = HttpResponse.new(client) 615 616 # Process each handler in registered order until we run out or one finalizes ...... 617 handlers.each do |handler| 618 handler.process(request, response) 619 break if response.done or client.closed? 620 end 621 622 # And finally, if nobody closed the response off, we finalize it. 623 unless response.done or client.closed?
mongrel-1.0.1/lib/mongrel.rb in "each" 617
612 613 # request is good so far, continue processing the response 614 response = HttpResponse.new(client) 615 616 # Process each handler in registered order until we run out or one finalizes ...... 617 handlers.each do |handler| 618 handler.process(request, response) 619 break if response.done or client.closed? 620 end 621 622 # And finally, if nobody closed the response off, we finalize it.
mongrel-1.0.1/lib/mongrel.rb in "process_client" 617
612 613 # request is good so far, continue processing the response 614 response = HttpResponse.new(client) 615 616 # Process each handler in registered order until we run out or one finalizes ...... 617 handlers.each do |handler| 618 handler.process(request, response) 619 break if response.done or client.closed? 620 end 621 622 # And finally, if nobody closed the response off, we finalize it.
mongrel-1.0.1/lib/mongrel.rb in "run" 736
731 if worker_list.length >= @num_processors 732 STDERR.puts "Server overloaded with #{worker_list.length} processors (#@num_p...... 733 client.close rescue Object 734 reap_dead_workers("max processors") 735 else 736 thread = Thread.new(client) {|c| process_client(c) } 737 thread[:started_on] = Time.now 738 @workers.add(thread) 739 740 sleep @timeout/100 if @timeout > 0 741 end
mongrel-1.0.1/lib/mongrel.rb in "initialize" 736
731 if worker_list.length >= @num_processors 732 STDERR.puts "Server overloaded with #{worker_list.length} processors (#@num_p...... 733 client.close rescue Object 734 reap_dead_workers("max processors") 735 else 736 thread = Thread.new(client) {|c| process_client(c) } 737 thread[:started_on] = Time.now 738 @workers.add(thread) 739 740 sleep @timeout/100 if @timeout > 0 741 end
mongrel-1.0.1/lib/mongrel.rb in "new" 736
731 if worker_list.length >= @num_processors 732 STDERR.puts "Server overloaded with #{worker_list.length} processors (#@num_p...... 733 client.close rescue Object 734 reap_dead_workers("max processors") 735 else 736 thread = Thread.new(client) {|c| process_client(c) } 737 thread[:started_on] = Time.now 738 @workers.add(thread) 739 740 sleep @timeout/100 if @timeout > 0 741 end
mongrel-1.0.1/lib/mongrel.rb in "run" 736
731 if worker_list.length >= @num_processors 732 STDERR.puts "Server overloaded with #{worker_list.length} processors (#@num_p...... 733 client.close rescue Object 734 reap_dead_workers("max processors") 735 else 736 thread = Thread.new(client) {|c| process_client(c) } 737 thread[:started_on] = Time.now 738 @workers.add(thread) 739 740 sleep @timeout/100 if @timeout > 0 741 end
mongrel-1.0.1/lib/mongrel.rb in "initialize" 720
715 716 if $tcp_defer_accept_opts 717 @socket.setsockopt(*$tcp_defer_accept_opts) rescue nil 718 end 719 720 @acceptor = Thread.new do 721 while true 722 begin 723 client = @socket.accept 724 725 if $tcp_cork_opts
mongrel-1.0.1/lib/mongrel.rb in "new" 720
715 716 if $tcp_defer_accept_opts 717 @socket.setsockopt(*$tcp_defer_accept_opts) rescue nil 718 end 719 720 @acceptor = Thread.new do 721 while true 722 begin 723 client = @socket.accept 724 725 if $tcp_cork_opts
mongrel-1.0.1/lib/mongrel.rb in "run" 720
715 716 if $tcp_defer_accept_opts 717 @socket.setsockopt(*$tcp_defer_accept_opts) rescue nil 718 end 719 720 @acceptor = Thread.new do 721 while true 722 begin 723 client = @socket.accept 724 725 if $tcp_cork_opts
mongrel-1.0.1/lib/mongrel/configurator.rb in "run" 271
266 # Works like a meta run method which goes through all the 267 # configured listeners. Use the Configurator.join method 268 # to prevent Ruby from exiting until each one is done. 269 def run 270 @listeners.each {|name,s| 271 s.run 272 } 273 274 $mongrel_sleeper_thread = Thread.new { loop { sleep 1 } } 275 end 276
mongrel-1.0.1/lib/mongrel/configurator.rb in "each" 270
265 266 # Works like a meta run method which goes through all the 267 # configured listeners. Use the Configurator.join method 268 # to prevent Ruby from exiting until each one is done. 269 def run 270 @listeners.each {|name,s| 271 s.run 272 } 273 274 $mongrel_sleeper_thread = Thread.new { loop { sleep 1 } } 275 end
mongrel-1.0.1/lib/mongrel/configurator.rb in "run" 270
265 266 # Works like a meta run method which goes through all the 267 # configured listeners. Use the Configurator.join method 268 # to prevent Ruby from exiting until each one is done. 269 def run 270 @listeners.each {|name,s| 271 s.run 272 } 273 274 $mongrel_sleeper_thread = Thread.new { loop { sleep 1 } } 275 end
/Users/wieck/Projects/nytmedia/trunk/framework/merb/server.rb in "cloaker_" 589
584 uri "/favicon.ico", :handler => Mongrel::Error404Handler.new("") 585 end 586 MerbHandler.path_prefix = @@merb_opts[:path_prefix] 587 588 trap("INT") { stop } 589 run 590 end 591 mconfig.join 592 end 593 594 def config
mongrel-1.0.1/lib/mongrel/configurator.rb in "call" 51
46 @defaults = defaults 47 @needs_restart = false 48 @pid_file = defaults[:pid_file] 49 50 if blk 51 cloaker(&blk).bind(self).call 52 end 53 end 54 55 # Change privilege of the process to specified user and group. 56 def change_privilege(user, group)
mongrel-1.0.1/lib/mongrel/configurator.rb in "initialize" 51
46 @defaults = defaults 47 @needs_restart = false 48 @pid_file = defaults[:pid_file] 49 50 if blk 51 cloaker(&blk).bind(self).call 52 end 53 end 54 55 # Change privilege of the process to specified user and group. 56 def change_privilege(user, group)
/Users/wieck/Projects/nytmedia/trunk/framework/merb/server.rb in "new" 580
575 mconf_hash = {:host => (@@merb_opts[:host]||"0.0.0.0"), :port => (port ||4000)} 576 if @@merb_opts[:user] and @@merb_opts[:group] 577 mconf_hash[:user] = @@merb_opts[:user] 578 mconf_hash[:group] = @@merb_opts[:group] 579 end 580 mconfig = Mongrel::Configurator.new(mconf_hash) do 581 listener do 582 uri( "/", :handler => MerbUploadHandler.new(@@merb_opts), :in_front => true) if...... 583 uri "/", :handler => MerbHandler.new(@@merb_opts[:merb_root]+'/public') 584 uri "/favicon.ico", :handler => Mongrel::Error404Handler.new("") 585 end
/Users/wieck/Projects/nytmedia/trunk/framework/merb/server.rb in "mongrel_start" 580
575 mconf_hash = {:host => (@@merb_opts[:host]||"0.0.0.0"), :port => (port ||4000)} 576 if @@merb_opts[:user] and @@merb_opts[:group] 577 mconf_hash[:user] = @@merb_opts[:user] 578 mconf_hash[:group] = @@merb_opts[:group] 579 end 580 mconfig = Mongrel::Configurator.new(mconf_hash) do 581 listener do 582 uri( "/", :handler => MerbUploadHandler.new(@@merb_opts), :in_front => true) if...... 583 uri "/", :handler => MerbHandler.new(@@merb_opts[:merb_root]+'/public') 584 uri "/favicon.ico", :handler => Mongrel::Error404Handler.new("") 585 end
/Users/wieck/Projects/nytmedia/trunk/framework/merb/server.rb in "run" 509
504 elsif @@merb_opts[:daemonize] 505 delete_pidfiles(@@merb_opts[:port]) 506 start(@@merb_opts[:port]) 507 else 508 trap('TERM') { exit } 509 mongrel_start(@@merb_opts[:port]) 510 end 511 512 end 513 514 def store_pid(pid,port)
script/merb in "?"