similar to: Getting the module name with ObjectSpace...

Displaying 20 results from an estimated 1000 matches similar to: "Getting the module name with ObjectSpace..."

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
2007 Jan 18
8
How can I find out which attribute is screwing up pluralize/singularize?
Hey there :) I''m creating this app on top of a legacy database, that has a mixture of auto_inc ids, non-''id'' named pks, non-integer-pks, foreign keys that end in _code instead of _id, etc. I have the model working great in the console, where I can create any modeled object and reference other objects without issues. However, I''m running into problems with
2006 Jul 09
1
Accessing the name of a controller''s module?
If I''m redirecting to a log in page, and saving the controller and action name in the session hash, how do I also save the controller module? After the log in is completed, I can''t redirect back to the originally directed page because it''s in a different controller module. For the controller action name I can use the ActionController instance method controller_name(),
2006 Apr 27
3
Routing problem
Hi, I am having a routing problem and can''t figure out why its happing. I have added the following line in my routing.rb file. map.connect ''name/:id'', :controller => ''controller_name'', :action => ''action_name'' When I use http://domain.com/controller_name/action_name/id then it works fine on the local machine using webrick
2006 Jan 18
0
subclasses_of - why does it ignore subclasses within modules?
ActiveSupport provides a method Object.subclasses_of, to give the subclasses of a given class. However, it ignores any subclass within a module, so : class A end class B < A end Object.subclasses_of(A) # returns [B] module C class D < A end end Object.subclasses_of(A) # returns [B], even though C::D is also a subclass of A class E < C::D end Object.subclasses_of(A) # returns
2009 Aug 10
0
A rails sitemap plugin
Hi, guys: I wrote a sitemap plugin for rails yesterday. This plugin will generate the public/sitemap.xml from config/sitemap.rb whose format is very familiar to config/routes.rb. I think it is very helpful if you have a website written by rails and want it to be crawled by spiders such as google, yahoo and baidu. The home page of the plugin is http://github.com/flyerhzm/sitemap/tree/master The
2009 Sep 13
0
regrex_crawler -- a crawler which uses regular expression to catch data from website
RegexpCrawler is a crawler which uses regular expression to catch data from website. It is easy to use and less code if you are familiar with regular expression. The project site is: http://github.com/flyerhzm/regexp_crawler/tree I give an example: a script to synchronize your github projects except fork projects, , please check example/github_projects.rb require ''rubygems''
2011 Jul 14
0
subclasses with inherited_resources?
I''m trying out inherited_resources and so far so good. However, one problem I''ve run into is that it''s very difficult to customize inherited_resource behaviour in subclasses. Looking through the source I see it uses things like undef_method and class_attribute. For example, if I have the following controllers: class ItemsController inherit_resources actions :new,
2009 Oct 13
3
Site map
Hi All... I am using generate_sitemap plugin to generate sitemap. It goes very well and creates sitemap as well. My problem is I want some links that are coming from vender/plugins. Can any one tell me how to get those links??? Thanks all... -- Posted via http://www.ruby-forum.com/.
2007 Jul 24
4
spec''ing helpers that use controller
Hi all, I''m in the process of creating rspecs for my helpers. One of the helpers in app/helpers/application_helper.rb looks like this: def page_name @page_name || "Define @page_name in #{controller.controller_name}::#{controller.action_name}" end The rspec is simply: it "should something" do page_name end
2008 Apr 09
2
sitemap for RoR
Hi all is there a plugin available by which i can generate a sitemap for my site automatically.. I mean when ever a page is added it will get listed in the sitemap? If you have implemented it do let me know thanks dhaval parikh -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google
2006 Jan 03
1
RequireResourceHelper for JS and CSS
The following was posted on my blog at http://blog.inquirylabs.com. A friend of mine recently expressed interest in this code snippet, so I thought I''d send it out to anyone else who''s interested. This module makes it a lot easier to ''require'' javascript and cascading stylesheet dependencies inside your views or controllers. By
2009 Jan 03
2
Some questions from a new webgen user
Hi everyone. Sorry if it is not the place to post questions about webgen. I use webgen5, i know it is not the stable version but i couldn''t understand how webgen4 worked, it''s easier with webgen5, and i won''t have to change my pages when it becomes mainstream ;) I try to build my homepage using webgen, and there are some things i don''t know how to do (i am sure
2006 Jan 02
2
Dynamic form tags
Hi all, I''m happily using "HowToReuseEditViewsForNewViews" found at: http://wiki.rubyonrails.com/rails/pages/HowToReuseEditViewsForNewViews There''s this comment there saying you only need the tag "<%= auto_form %>" when using the code below. Can somebody tell me if that will work when extending it with model_name (some how)? I have several new_*
2006 Jul 12
3
How to get the current URL?
Hi, how can I get the current URL withing a controller? There seems to be no appropriate method in ActionController::Base. I''m creating a site, which requires a login for some pages. I''m using before_filter for authentication. My idea was to store the currect URL in a session before redirecting to the login page and then redirect to this URL after successful authenfication.
2008 Dec 07
2
Strange 500 Error with namespace::controller#action appearing in reload only
The portion of the log linked below is two requests directly out of the log file for the same action. The first request was from me putting the address in the browser directly (but can be duplicated by linking to the url anywhere in the app). When I reload the browser on this url, I get a strange error. To the user, the action appears to load fine, but I''m getting a 500 error in the log
2006 Apr 28
0
available: google sitemap for rails project
Hi, Google Sitemaps (https://www.google.com/webmasters/sitemaps/) is a way to help Google''s crawler on your website. I''ve published a little script to generate, from a rails project, a urllist file usable with the Google sitemap generator. You drop the script in your RAILS_ROOT/lib directory, edit it to set the base url, and you''re set. Run it with ruby script/runner
2007 Sep 18
2
rSpec / Nested Routes / Mocks
I''m having a terrible time trying to test a nested route with rSpec. I can''t seem to tell rSpec to expect the call @item.user. The following error message plagues me not matter how I try to fuss with the mock: Spec::Mocks::MockExpectationError in ''ItemsController handling POST / items should redirect to the new course on successful save'' Mock
2006 Oct 24
1
Broken thread Safe connection Management on Mysql (Mysql too many connections errors)
Hi, There is an issue on socket connection with backgroundrb (rev 47) and mysql backend: after a certain number of job you reach the mysql connection limit as socket are never closed and nobody can connect to mysql anymore till you stop the backgroundrb daemon. Already reported on: http://rubyforge.org/pipermail/backgroundrb-devel/2006-July/000066.html,
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