Answer the question
In order to leave comments, you need to log in
How to render template from one controller to another?
There are two controllers and two templates respectively. But you need to output data from these two controllers to one page, say, to the template of the first controller, how to be? I tried render like here - rusrails.ru/layouts-and-rendering-in-rails that is, attach the second template to the first one =render "messages/message". It doesn't work because it needs methods from the second controller, undefined method for each errors rained down, and so on. What to do in this case? Merge controllers?
Answer the question
In order to leave comments, you need to log in
You are thinking a little wrong. In order for the controller to work, a request must come to it. Those. do ajax-request to it.
I'm not very good at ruby, but usually a controller action is a simple method that can be called anywhere.
for example there is
class controller_1 {
public function action_1(){
return $template_1->render()
}
}
class controller_2 {
public function action_2(){
$param = (new controller_1)->action_1();
return $template_2->render($param)
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question