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’,
My problem is very similar to the the one described in a post to this
Nobody ever explained it then. I corresponded with the February poster,
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
well as the book authors (Dave T., ‘Agile Web D. with
Chad F., ‘Rails Recipes’) claim to make cross-controller calls. And
cross-controller invocations simply didn’t work, the whole point of
Components would be greatly diminished.
I also read this nice ‘components’ doc
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
from either location. So why is it ‘undefined’?