Displaying 20 results from an estimated 34 matches for "objectspac".
Did you mean:
objectspace
2007 Mar 21
0
Getting the module name with ObjectSpace...
Hey :)
I''m trying to create a method for making a sitemap dynamically. It
works great for flat sites where you simply have your controllers in
the app/controllers directory. In this case, I can extract the
controller names like,
@controllers
ObjectSpace.subclasses_of(ActionController::Base).each do |obj|
@controllers["#{obj.controller_name}"] = obj
end
However, now I''ve divided the site into modules, that is, I have for
instance both Store::ItemsController and Manage::ItemsController,
which reside in app/controllers/st...
2006 Oct 24
1
Broken thread Safe connection Management on Mysql (Mysql too many connections errors)
...more as mysql socket are not closed
In my humble opinion there are two reasons for it:
- ActiveRecord::Base.allow_concurrency = true
That will make every thread open it''s own socket to mysql
- Mysql adapter implementations (RAILS or gems) that close connection on
Garbage connexion (using ObjectSpace.define_finalizer )
There is probably a memory leak on connections as the Proc finalizer is
not be executed when worker thread is killed (= connections are not
GC). In this case the only way to release the sockets is to close the
backgroundrb daemon.
Those two phenomenons lead to an accumula...
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 ag...
2007 Oct 12
5
deciphering objects.log
Howdy -- I''ve been tracking down mem leaks (oh, the fun...), and I think
there is a clue in objects.log. There are a few mentions of this file, but
usually Zed saying "look at this file and it will help you". Can anyone clue
me in to what the actual columns mean?
18,Float,143952,256821,112869,,,
18,String,39543,41693,2150,24.727076,55.526376,2308.000000
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:
2008 May 18
2
Pure win32-thread library?
Hi all,
Here''s my initial stab at a pure Ruby win32-thread library that doesn''t
work at all. I''m not sure how to pass the start address of the arguments
to the callback. I thought about Marshal, but you can''t marshal a proc.
BTW, the CreateThread method in windows-pr needs to be updated for this
to have any hope of success.
Any ideas?
Thanks,
Dan
#
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
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...
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
...--
lib/unicorn/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
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
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 Feb 20
0
Object Finalizers help
Heya guys,
This one is bothering me as its evading my eye. I''m trying to set a
callback on finalization of an object, ie: a finalizer set through a
plugin to the model.
Example In Plugin:
def acts_as_goat
class_eval do
ObjectSpace.define_finalizer(self, Proc.new {self.conn.close} )
end
end
class UberGoat < ActiveRecord::Base
acts_as_goat
end
Anyways, it seems to not be calling the finalizer? Is this the correct
way to set a finalizer or am I going about it the wrong way. I need to
close a socket connection _af...
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
2006 Jan 19
0
Problem with an Tree-like object hierarchy (ActiveRecord acts_as_tree)
...m there:
def unfreeze_taxtree
if taxtree_frozen then return Marshal.load(session[:tax_tree])
else return nil end
end
def freeze_taxtree(tax)
return session[:tax_tree] = Marshal.dump(tax)
end
def get_tax_from_freezer(tax_id)
@@tax_tree = unfreeze_taxtree
ObjectSpace._id2ref(@@tax_tree.find_tax(tax_id))
end
So tax are the nodes and tax_tree the ... well ... tree.
I did the marshaling and retrieving via object id because I was
getting paranoid about the objects not being the original ones after
unfreezing from the session cache.
Before the first freezin...
2006 Feb 20
1
Object finalization help
Heya guys,
This one is bothering me as its evading my eye. I''m trying to set a
callback on finalization of an object, ie: a finalizer set through a
plugin to the model.
Example In Plugin:
def acts_as_goat
class_eval do
ObjectSpace.define_finalizer(self, lambda {self.conn.close} )
end
end
class UberGoat < ActiveRecord::Base
acts_as_goat
end
Is this the correct way to set a finalizer or am I going about it the
wrong way. I need to close a socket connection _after_ the model goes
out of scope where GC usually happen...
2005 May 08
1
ruby destructor hooks
...he subscribers list. When
an event is broadcast, its "notify" method is called, it gives a "pure
virtual method call" error (wxruby 0.6.0).
I''ve tried several different things to clean up the subscribers list as
controls are destroyed, but without success:
WeakRef
ObjectSpace.define_finalizer(subscriber)
subscriber.evt_close() { | e | delete_subscriber(subscriber) }
The last seems to be the most promising, but it doesn''t work for all the
control types that can be subscribers - only for frames. Is there
something universal to all Wx controls that I could try...
2007 Sep 18
2
Making attachment_fu polymorphic
...ttachable_id and :attachable_type to whatever you
are using. Also, be sure to
# update the default value for ''path'' in the file_system case
from ''attachements''
# to whatever your table name is.
def initialize(attributes={})
@p = ObjectSpace._id2ref(#{parent})
path = if "#{@@attachment_config[:path_prefix]}".to_s == ""
pth = case "#{@@attachment_config[:storage]}".to_s
when "file_system"
"public/attachments&q...
2005 Jul 26
3
Wx::Html* widgets
...indow, Wx::HtmlEasyPrinting, 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