I want to redirect the user to the event_calendar_path
when it goes too many months ahead using the link "next month" showing up a flash message saying "You cannot go more than 6 months ahead".
I would like to display it as an error message, but it doesn't show. I tried with :notice, :info, :error, but only :notice gets displayed actually.
This is what I have in my application.html.haml
file:
- flash.each do |key, msg|
- if key == :notice
.alert.alert-success= msg
- elsif key == :error
.alert.alert-error= msg
- elsif key == :info
.alert.alert-info= msg
- else
.alert.alert-block= msg
And this is what I'm doing to display the flash message:
if @current_month > Date.today.month + 6
flash[:error] = "You cannot go more than 6 months ahead"
redirect_to event_calendar_path @event_calendar, :group_id => @group.id
return
end
If i replace :error
with notice it works, otherwise I get no message.
Before I was using the short form :notice => "Message"
, but then I changed it to make sure it was not an issue using that form to display messages, but I'm still not able to display it.
What can be the cause for this behaviour? How can I fix it?
Thanks.