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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With