Randy Parker
2006-Aug-14 15:48 UTC
[Rails] undefined method ''render_component_as_string'' - why?
I want to put a ''search_box'' text_field in the header of each page. The search_box is implemented in a controller named ''users''. (so Controller_A is calling a component in Controller_B) When I add this line to my ''controllers/application.rb'' file, I don''t understand why I get and ''undefined method'' error. After all, "class ApplicationController < ActionController::Base". @sbox = render_component_as_string(:controller=>''users'', :action=>:search) My problem is very similar to the the one described in a post to this list 6 months ago: http://lists.rubyonrails.org/pipermail/rails/2006-February/016759.html Nobody ever explained it then. I corresponded with the February poster, who points out that it 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, ''Agile Web Development with Rails'', Chad Fowler, ''Rails Recipes'') 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 leaves a little unclear if both ''render_component'' and ''render_component_as_string'' can both be called from either a View or Controller, but 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/13911981/attachment.html
Possibly Parallel Threads
- Undefined Method error for call to ''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
- configure for ARM Linux