Having an issue in my Rails 7 app of alerts not showing up.
notices
, however, are.
I am displaying alerts in application.html.erb
using <%= alert %>
<%= render partial: "shared/navbar" %><div class="px-6"><div class="mt-6"></div><div><% if notice %><div class="notification is-success is-light text-center"><%= notice %></div><% end %><% if alert %><% debugger %><div class="notification is-danger is-light text-center"><%= alert %></div><% end %><%= yield %></div></div>
I have added a "FAILED" logger to my controller action, which I am seeing in the Rails logs. This proves to me that we are indeed falling into the "else" condition, and the new
page is being rendered upon failure to create a new object. However, I do not see the alert message.
def create@rescue = AnimalRescue.new(rescue_params)respond_to do |format| if @rescue.save format.html { redirect_to animal_rescue_url(@rescue), notice: "Rescue was successfully created." } format.json { render :show, status: :created, location: @rescue } else Rails.logger.info "FAILED" format.html { render :new, status: :unprocessable_entity, alert: "Unable to create rescue." } format.json { render json: @rescue.errors, status: :unprocessable_entity } endend
end