I have an action, which sets an instance veriable before :edit
and :new
actions in a controller. This works if I call these actions directly in a request. However, if I call :update
or :create
and they fail, after which within a respond_to
block format.html { render action: :edit }
is executed, the before_action
does not get triggered. Why is that?
Because render action: :edit
doesn't actually call controller action, but only renders edit
template.
You'll find more info in Rails guides: