Randy Parker
2006-Aug-14 19:29 UTC
[Rails] Undefined Method error for call to ''render_component_as_string''- Why?
I want to put a ''search_box'' text_field in the header of each page. This common header template is implemented in ''views/layouts/application.rhtml''. The search_box is implemented in a controller named ''users''. (so ApplicationController is calling an :action in UserController) When I add this line to my ''controllers/application.rb'' file, I don''t understand why I get an ''undefined method'' error. After all, "class ApplicationController < ActionController::Base". @sbox = render_component_as_string(:controller=>''users'', :action=>:search) This problem was also described in a post to this list 6 months ago: http://lists.rubyonrails.org/pipermail/rails/2006-February/016759.html Nobody replied. I corresponded with the February poster, who points out that render_component_as_string() is ''protected'', and suggests that is why Controller_A can''t call an Action in Controller_B. But some folks on the Site5 forums, as well as the book authors (Dave Thomas, Chad Fowler) claim to make cross-controller calls. And if cross-controller invocations simply didn''t work, the whole point of Components would be greatly diminished. I also read this nice ''components'' doc http://manuals.rubyonrails.com/read/chapter/71 ... which does not make it clear if both ''render_component'' and ''render_component_as_string'' can both be called from either a View or Controller. I think the doc is saying that either method can be called from either location. So why is it ''undefined''? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060814/8a601184/attachment.html
Randy Parker
2006-Aug-14 22:06 UTC
[Rails] Re: Undefined Method error for call to ''render_component_as_string''- Why?
It seems strange to me that the WEBrick logs shows the pages being produced with back-rev gem libraries - for example, actionpack-1.12.1 instead of 1.12.5. But I do find support for render_component_as_string even in the "...1" version library. So perphaps this is odd, but not the cause of the problem? (I''m running 64-bit CentOS, Rails 1.1.6) =====================================NoMethodError (undefined method `render_component_as_string'' for ApplicationController:Class): /app/controllers/application.rb:11 /usr/lib64/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in `load'' /usr/lib64/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:56:in `require_or_load'' /usr/lib64/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:30:in `depend_on'' /usr/lib64/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:85:in `require_dependency'' /usr/lib64/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:69:in `prepare_application'' /usr/lib64/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:37:in `dispatch'' /usr/lib64/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in `handle_dispatch'' /usr/lib64/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in `service'' /usr/lib64/ruby/1.8/webrick/httpserver.rb:104:in `service'' /usr/lib64/ruby/1.8/webrick/httpserver.rb:65:in `run'' /usr/lib64/ruby/1.8/webrick/server.rb:173:in `start_thread'' /usr/lib64/ruby/1.8/webrick/server.rb:162:in `start_thread'' /usr/lib64/ruby/1.8/webrick/server.rb:95:in `start'' /usr/lib64/ruby/1.8/webrick/server.rb:92:in `start'' /usr/lib64/ruby/1.8/webrick/server.rb:23:in `start'' /usr/lib64/ruby/1.8/webrick/server.rb:82:in `start'' /usr/lib64/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in `dispatch'' /usr/lib64/ruby/gems/1.8/gems/rails-1.1.2 /lib/commands/servers/webrick.rb:59 /usr/lib64/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' /usr/lib64/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' /usr/lib64/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30 /usr/lib64/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' /usr/lib64/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' i 08-14 17:55:47 Rendering /usr/lib64/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/templates/rescues/layout.rhtml (500 Internal Error) ======================================-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060814/a3ddf290/attachment-0001.html
Randy Parker
2006-Aug-15 15:18 UTC
[Rails] Re: Undefined Method error for call to ''render_component_as_string''- Why?
I still don''t know why WEBrick and Mongrel were so fond of back-rev libs, but running "gem cleanup" got rid of all but the most recent ones. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060815/694cbf81/attachment-0001.html
Apparently Analagous Threads
- undefined method ''render_component_as_string'' - why?
- render_component vs. render_component_as_string?
- using routes.rb from inside a controller / render_component_as_string / generally stumped
- url_for leave out ''index'' action
- calling controller and caching from a sweeper class