Displaying 16 results from an estimated 16 matches for "each_object".
2007 Nov 16
1
Temporaly silencing the rails log.
Hi! I want to do what subject say. Is there any elegant way to do this:
???
# Silence the log inside the block attached to the method call.
def silence_logger
orig= nil
ObjectSpace.each_object(::Logger) do |logger|
logger.info "-" * 80
logger.info "Quieting the log..."
orig= logger.level
logger.level= ::Logger::FATAL
end
yield
ObjectSpace.each_object(::Logger) do |logger|
logger.level= orig
logger.info "Log is alive again!"...
2006 Apr 07
3
List of all Models
Anyone know a pretty way to get a list of all Models?
That is, a list of all classes which inherit from ActiveRecord:Base
I can''t seem to figure it out!
The best I''ve got is to list the /app/models directory... but, that is
*dirty*.
-hampton.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 Jan 19
3
Why does Object.subclasses_of ignore subclasses within modules?
ActiveSupport provides a method Object.subclasses_of, shown below:
def subclasses_of(*superclasses)
subclasses = []
ObjectSpace.each_object(Class) do |k|
next if (k.ancestors & superclasses).empty? ||
superclasses.include?(k) || k.to_s.include?("::") ||
subclasses.include?(k)
subclasses << k
end
subclasses
end
Can anyone shine some light on why it (very deliberately) doesn't
return subcl...
2008 Jul 01
4
Exceptions available in Ruby on Rails
Hi,
Can anybody list out what are all the exceptions available in ROR?
Thanks in advance...
Karthik.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2012 Oct 02
3
[PATCH] chowning /dev/null should be guarded against
...corn/util.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/unicorn/util.rb b/lib/unicorn/util.rb
index cde2563..6b6cca2 100644
--- a/lib/unicorn/util.rb
+++ b/lib/unicorn/util.rb
@@ -15,7 +15,7 @@ module Unicorn::Util
def self.chown_logs(uid, gid)
ObjectSpace.each_object(File) do |fp|
- fp.chown(uid, gid) if is_log?(fp)
+ fp.chown(uid, gid) if is_log?(fp)&& fp.path != "/dev/null"
end
end
# :startdoc:
-- 1.7.12.1
2008 Mar 12
12
Mongrel has crashed
Hi,
my mongrel has crashed with following errors in the logfile:
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready. TERM => stop. USR2 => restart. INT => stop (no
restart).
** Rails signals registered. HUP => reload (without restart). It might
not work well.
** Mongrel 1.1.3 available at 0.0.0.0:3000
**
2006 Jan 05
1
Looping through all models in the application
Hello.
I have an application that depends on a table/model
(ModelInternationalization) that provides international translations in
various languages for all the model/table and columns names as well as
some other stuff (whether the column is visible on forms, dropdowns,
lists, reports etc).
I need to create a management interface for this translation stuff (the
plaintext stuff, btw, will be
2010 Jul 14
1
ActiveRecord::Observer, update_all and has_many
Hi,
I''m using an ActiveRecord::Observer to log users changing data in my
application. However, I''ve noted that adding an item to a has_many
relationship gets logged, but removing the item does not. That is:
@product.users << user
is logged, but:
@product.users.delete(user)
is not.
I''ve dug into ActiveRecord and found that the underlying issue is that
the
2005 Jul 26
3
Wx::Html* widgets
...tmlEasyPrinting, etc..
The error I got is "uninitialized constant Wx::HtmlWindow". The code
is correct since I''m trying to execute samples in the html/ directory.
All other samples work. I can''t even see that widgets doing
require ''wxruby''; ObjectSpace.each_object(Class) {|c| p c if c.name =~ /Wx/}
I see all the widgets but the html* ones.
Is this a problem of mine or the html widgets aren''t still bound to Ruby?
I''m using WxRuby 0.6.0 on GNU/Linux (compiled on my pc)
Thanks, Domenico
2012 Apr 12
8
Background jobs with #fork
Hi
I''ve migrated from Passenger to Unicorn about a week ago. It''s great.
Great transparency and management, thanks for this great software!
A few of my Rails applications start background jobs using
Kernel#fork. Of course, the ActiveRecord connections are closed and
reopened again in the parent and child processes. The child process
also does its job.
Unfortunately, it seems
2007 Jan 27
0
Debugging stale backgroundrb
.../releases/20070125084747/vendor/plugins/backgroundrb/server/lib/backgroundrb_server.rb:301:in
`run''",
"/u/apps/learnbyrote/current/script/backgroundrb:29"]
It''s apparent that some Slave is waiting for some process to exit.
After issuing "eval "ObjectSpace.each_object(Slave){|x| p x if
!x.status}"" I''ve got a strange result though:
#<Slave:0x34c0fb0 @shutdown=false,
@obj=#<BackgrounDRb::Worker::WorkerResults:0x34c0fc4
@worker_results={}, @initial_do_work=true, @results={}, @args=nil,
@jobkey=:backgroundrb_results>, @lifeline=#<Sla...
2011 Feb 16
1
Forking for background processing with rails/unicorn
Hello,
I''ve been working for a few days on a problem which, after tracking it
down, seems to be related to unicorn. I''m hoping that somebody might
be able to help with information about what''s going on.
In the Rails 3 application that I support, we sometimes fork during a
web request in order to do background processing behind the scenes
without the user (and the
2006 Apr 05
9
Is eval the only way?
Hi,
I''m trying to write some methods which use a parameter to represent a
Class name.
A very simplistic example:
def foo(class_name, conditions)
x = class_name.find(:all, :conditions => "#{conditions}")
end
Unfortunately, this does not work. The only way around this problem
that I can think of is to use eval:
def foo(class_name, conditions)
x = eval
2006 Mar 10
0
WEBrick crashing
...all ms/call name
138.04 3.80 3.80 1 3796.00 3796.00
Profiler__.start_profile
36.80 4.81 1.01 873 1.16 2.00 Array#include?
27.35 5.56 0.75 3966 0.19 0.19 Module#==
21.64 6.16 0.60 1 595.00 2000.00
ObjectSpace.each_object
5.71 6.31 0.16 865 0.18 0.18
Module#included_modules
5.13 6.45 0.14 1 141.00 2688.00
Module#included_in_classes
1.13 6.48 0.03 99 0.31 0.31 Kernel.send
0.58 6.50 0.02 5 3.20 3.20 Array#+
0.58...
2006 Mar 26
4
edge and 1.8.2/1.8.4 issues
I recently upgraded to 1.8.4 to try out mongrel, and so far have been in
a kind of hell where I can''t get my app working!
Currently running (or trying to run):
Ruby version 1.8.4 (i386-mswin32)
RubyGems version 0.8.11
Rails version 1.0.0
Active Record version 1.13.2
Action Pack version 1.11.2
Action Web Service version 1.0.0
Action Mailer version 1.1.5
Active Support version
2007 Dec 19
8
Segmentation fault in Mongrel when run with --debug
....rb line 128 which is
# stolen from Robert Klemme
class Objects < GemPlugin::Plugin "/handlers"
include Mongrel::HttpHandlerPlugin
121 def process(request,response)
122 begin
123 stats = Hash.new(0)
124 lengths = {}
125 begin
126 ObjectSpace.each_object do |o|
127 begin
128 if o.respond_to? :length
129 len = o.length
130 lengths[o.class] ||= Mongrel::Stats.new(o.class)
131 lengths[o.class].sample(len)
132 end
133 rescue Object
134 end
anybody el...