I want to put a ‘search_box’ text_field in the header of each page.
common header template is implemented in
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’,
This problem was also described in a post to this list 6 months ago:
Nobody replied. I corresponded with the February poster, who points out
that render_component_as_string() is ‘protected’, and suggests that is
Controller_A can’t call an Action in Controller_B. But some folks on the
Site5 forums, as well as the book authors (Dave T., Chad F.)
to make cross-controller calls. And if cross-controller invocations
didn’t work, the whole point of Components would be greatly diminished.
I also read this nice ‘components’ doc
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’?
It seems strange to me that the WEBrick logs shows the pages being
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
“…1” version library. So perphaps this is odd, but not the cause of
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:inload’
i 08-14 17:55:47 Rendering
(500 Internal Error)
I still don’t know why WEBrick and Mongrel were so fond of back-rev
but running “gem cleanup” got rid of all but the most recent ones.