You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a lot of inconsistency in the way we write the controllers. I would like to
keep it consistent by deciding once for all how we nest respond_to and if model.save;
make sure that the flash message is always shown (both for confirming success and for notifying failure);
make sure that we always treat the failures in model creation/update.
Regarding respond_to I think a reasonable way of doing this is not to add empty format.xxx and let the base figure out the available formats by looking into the files unless this adds latency. In other words, when there is nothing to add to the format.xxx like in the following example:
There is a lot of inconsistency in the way we write the controllers. I would like to
respond_to
andif model.save
;Regarding
respond_to
I think a reasonable way of doing this is not to add emptyformat.xxx
and let the base figure out the available formats by looking into the files unless this adds latency. In other words, when there is nothing to add to theformat.xxx
like in the following example:I prefer it to be more concise like the following
The controller will automatically render the appropriate view files in case of success.
It is also important not to forget to send (and update) the flash message in case of success. For
turbo_stream
format, this involvesflash.now
:flash.now[:success] = "flash.generic.success.create"
<%= turbo_stream.replace("flash-messages", partial: "shared/flash") %>
The text was updated successfully, but these errors were encountered: