Can I call an action in another action (in a rails controller)?
ruby-on-rails
Solution
Yes you can, if it is in the same controller.
Calling `zoo` will provide the template for zoo with instances for `@x` and `@a`. Neither foo or bar will be rendered. If you have explicitly set a `render` method, then you might get a double render error, unless you `return` before the second render is called.
def foo
@x = 1
end
def bar
@a = 2
end
def zoo
foo
bar
end
Problem
When an action in a controller has been called, can I then call another action from that action? And what would happen if both actions have some template to render?