I have an odd error. I have the following module: module ActionController module SslSupport def self.included(base) raise "#{base} does not define url_for" unless base.method_defined?(:url_for) unless base.respond_to?(:url_for_without_ssl_supprt) base.send :include, InstanceMethods base.send :alias_method_chain, :url_for, :ssl_support end end module InstanceMethods def url_for_with_ssl_support(options) new_options = options.dup if options.kind_of?(Hash) new_options.merge!({ :only_path => false }) if request.ssl? ^ url_ssl?(new_options) if url_ssl?(new_options) new_options.merge!({ :protocol => ''https'' }) if [''development''].include?(ENV[''RAILS_ENV'']) new_options.merge!({ :port => 3001, :host => request.host }) end end new_options.delete(:ssl) end url_for_without_ssl_support(new_options) end private def url_ssl?(options) case options when Hash protocol = options[:protocol] || ''http://'' return options[:ssl] || protocol =~ /^https/ when String return options =~ /^https/ else return self.class.method_defined?(:request) ? request.ssl? : false end end end end end It is included in app/controllers/application.rb and in ActionView::Base. If I run ruby test/functional/people_controller_test.rb or ruby test/functional/ account_controller_test.rb, everything runs fine. If I run rake test:functionals, however, I get a "stack level too deep" within url_for within those two test classes. Example output: test_spec {The Account controller A guest (in general)} 001 [should be able to view the sign-up page](The Account controller A guest (in general)): ActionView::TemplateError: stack level too deep On line #8 of app/views/account/start.rhtml 5: <h1>Create a free account in three steps:</h1> 6: 7: <ol> 8: <li>a. <%= link_to ''Choose'', :action => ''choose'' %></li> 9: <li>b. Create</li> 10: <li>c. Customize</li> 11: </ol> lib/action_controller/ssl_support.rb:36:in `url_ssl?'' lib/action_controller/ssl_support.rb:19:in `url_for_without_ssl_support'' lib/action_controller/ssl_support.rb:28:in `url_for'' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb: 70:in `send'' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb: 70:in `url_for_without_ssl_support'' lib/action_controller/ssl_support.rb:28:in `url_for'' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb: 136:in `link_to'' I figured that my self.included(base) would guard against this, but it doesn''t seem to work. Any thoughts? -Gaius --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
gcnovus
2007-Aug-30 21:32 UTC
Re: alias_method_chain stack level too deep in Rake test only
I suppose I meant ''method_defined?'' instead of ''respond_to?'' but that doesn''t change the problem. -Gaius On Aug 30, 5:29 pm, gcnovus <james.a.ro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have an odd error. I have the following module: > > module ActionController > module SslSupport > > def self.included(base) > raise "#{base} does not define url_for" unless > base.method_defined?(:url_for) > unless base.respond_to?(:url_for_without_ssl_supprt) > base.send :include, InstanceMethods > base.send :alias_method_chain, :url_for, :ssl_support > end > end > > module InstanceMethods > > def url_for_with_ssl_support(options) > new_options = options.dup > > if options.kind_of?(Hash) > new_options.merge!({ :only_path => false }) if request.ssl? > ^ url_ssl?(new_options) > if url_ssl?(new_options) > new_options.merge!({ :protocol => ''https'' }) > if [''development''].include?(ENV[''RAILS_ENV'']) > new_options.merge!({ :port => 3001, :host => > request.host }) > end > end > new_options.delete(:ssl) > end > > url_for_without_ssl_support(new_options) > end > > private > > def url_ssl?(options) > case options > when Hash > protocol = options[:protocol] || ''http://'' > return options[:ssl] || protocol =~ /^https/ > when String > return options =~ /^https/ > else > return self.class.method_defined?(:request) ? request.ssl? : > false > end > end > > end > > end > end > > It is included in app/controllers/application.rb and in > ActionView::Base. If I run > > ruby test/functional/people_controller_test.rb or ruby test/functional/ > account_controller_test.rb, everything runs fine. If I run rake > test:functionals, however, I get a "stack level too deep" within > url_for within those two test classes. > > Example output: > > test_spec {The Account controller A guest (in general)} 001 > [should be able to view the sign-up page](The Account controller > A guest (in general)): > ActionView::TemplateError: stack level too deep > On line #8 of app/views/account/start.rhtml > > 5: <h1>Create a free account in three steps:</h1> > 6: > 7: <ol> > 8: <li>a. <%= link_to ''Choose'', :action => ''choose'' %></li> > 9: <li>b. Create</li> > 10: <li>c. Customize</li> > 11: </ol> > lib/action_controller/ssl_support.rb:36:in `url_ssl?'' > lib/action_controller/ssl_support.rb:19:in > `url_for_without_ssl_support'' > lib/action_controller/ssl_support.rb:28:in `url_for'' > vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb: > 70:in `send'' > vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb: > 70:in `url_for_without_ssl_support'' > lib/action_controller/ssl_support.rb:28:in `url_for'' > vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb: > 136:in `link_to'' > > I figured that my self.included(base) would guard against this, but it > doesn''t seem to work. Any thoughts? > > -Gaius--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe Matching Threads
- [PATCH 3/4] common/qemuopts: use the old pointer as realloc pointer
- [nbdkit PATCH] connections: Don't use uninit memory on early client EOF
- [PATCH 0/4] common: Add a simple mini-library for handling qemu command and config files.
- [nbdkit PATCH] connections: Implement NBD_OPT_INFO
- Does Ferret have problems with #alias_method_chain ?