Flash message not being displayed

I can’t seem to get a flash message to display in my app after catching
an exception.

I have a method that loads the current user based on the current
subdomain, the current_subdomain_user method throws an
ActiveRecord::RecordNotFound if it can’t find a user for a particular

I have a before_filter that calls this method and catches any record not
found exceptions, sets a flash message and redirects.

The problem is that the flash message isn’t being displayed, I can’t
understand why not. Any help would be much appreciated. Below is the
before filter

def user_required
current_subdomain_user # this method will raise an exception if
the current subdomain user can’t be found
rescue ActiveRecord::RecordNotFound
flash[:error] = “Couldn’t find the user #{current_subdomain}”
redirect_to root_url(:subdomain => false)

Do you have something like

<%= flash[:error] %>

in your layout or view file?

On Jun 22, 8:43 pm, Oliver Nightingale <rails-mailing-l…@andreas-

Yeah, I should have mentioned that sorry.

I can display flash messages, including error messages elsewhere in my
application, I have the following code for displaying the flash messages
in my layout.

<%= flash_messages %>

def flash_messages
messages = []
%w(notice warning error).each do |msg|
messages << content_tag(:div, html_escape(flash[msg.to_sym]), :id
=> “flash-#{msg}”) unless flash[msg.to_sym].blank?

Not sure if you got this answered but a guess would be because the
flash hash is persisted only across the same domain… your subdomain
doesn’t see the flash message.

On Jun 22, 12:39 pm, Oliver Nightingale <rails-mailing-l…@andreas-