inherited_resources icon indicating copy to clipboard operation
inherited_resources copied to clipboard

No flash messages

Open retro opened this issue 16 years ago • 16 comments

It seems that flash messages are gone now that I've upgraded to 1.0.3 version. It is not related to keys of flash messages, because when I try to inspect flash I get empty hash. When I set flash message directly it works.

retro avatar Feb 14 '10 17:02 retro

Are you sure you have the gem responders 0.4.2 or 0.4.3 installed? Can you try to isolate this issue in a fresh app?

josevalim avatar Feb 14 '10 23:02 josevalim

I am having the exact same problem, but only in my cucumber steps, not when viewing the site in my browser. Additionally, it's only failing for some of my models, not all of them. It was working fine last night and I did not update any gems on my system. I switched git branches and made a few changes to my CSS, switched back to my master branch, and that's when I started encountering errors.

curthasselschwert avatar Feb 18 '10 11:02 curthasselschwert

Are you trying to use flash.now? Or just flash? More info here:

http://groups.google.com/group/inherited_resources/browse_thread/thread/fe6883d5aed98c02

josevalim avatar Mar 13 '10 09:03 josevalim

I was using flash[:notice], and then I would do flash.delete[:notice]. I wili check if it is working correctly with setting flash.now

retro avatar Mar 13 '10 13:03 retro

I have the same issue with Rails 3.0.0.beta, inherited 1.1.0, has_scope 0.4.2 and responders 0.5.4.

I tried to debug without success. Any updates?

sobrinho avatar Mar 22 '10 08:03 sobrinho

This is odd guys. Can you try to isolate in a smaller application, so I can debug it?

josevalim avatar Mar 22 '10 08:03 josevalim

I'll try to find some time this week to debug this.

retro avatar Mar 22 '10 08:03 retro

Guys, I need a way to reproduce this. Because I definitely can't.

josevalim avatar Mar 25 '10 09:03 josevalim

I will create a fresh app tonight to reproduce this ;)

sobrinho avatar Mar 25 '10 12:03 sobrinho

I believe that the problem is in responders. I had the same problem which I managed to get around by switching the lines in to_html so that set_flash_message comes before super.

def to_html
  set_flash_message! if set_flash_message?
  super
end

To me, it sounds more logical that the flash message should be set before the view is being rendered.

kejiro avatar Mar 25 '10 13:03 kejiro

Yeah, it makes sense. So you were all using flash.now?

josevalim avatar Mar 25 '10 13:03 josevalim

I was using standard flash, or rather, I let inherited_resources handle everything.

It would be nice to have it use flash.now on failure, but it would probably require a bit more logic for that seeing that giving the :flash_now in the respond_with call would trigger it for both success and failure.

kejiro avatar Mar 25 '10 13:03 kejiro

Funny, this should not happen with standard flash.

josevalim avatar Mar 25 '10 13:03 josevalim

Well, what I meant was that the flash message did show up after a redirect, but when rendering instead (like in case of an validation error) it never showed up.

I did assume that was what this issue was about since that was what I had problems with, and it seemed similar.

However, it is not using flash.now now since the message is still available for the next action as well. Maybe adding a flag @use_flash_now_on_failure would help me in that case, but I don't think that have anything to do with this issue :)

kejiro avatar Mar 25 '10 13:03 kejiro

Inherited Resources forwards all options to respond_with, so you can do:

def create
  create!(:flash_now => true)
end

What I can do to support is:

def create
  create!(:flash_now => :on_failure)
end

I will work on it.

josevalim avatar Mar 25 '10 13:03 josevalim

FIXED. Install new responders please. :D

josevalim avatar Mar 26 '10 11:03 josevalim