I have a controller action in Rails as follows:
def register if logged_in? current_user().courses << Course.find(params[:course_id]) flash.notice = 'Successfully registered!' redirect_to '/' else flash.alert = "You must be logged in" redirect_to '/courses' endend
This is rendered in the /courses
view as
<% if flash[:notice] %><div class="notice"><%= flash[:notice] %></div><% end %>
However, when I go to a different route and then return to /courses
, the notice briefly flashes before going away. Is this normal behavior? If so, why is it occurring? If not, what am I doing wrong?