Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4616

Rails flash.notice briefly appearing after reloads

$
0
0

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?


Viewing all articles
Browse latest Browse all 4616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>