modifying flash from model hooks
It doesn't currently seem possible to modify the flash[:notice] (or any other type) from a model hook. In controller_issues_edit_after_save() I would like to be able to do something like:
context[:controller].flash[:notice] << 'something to append to the flash message'
In my usage, context[:controller] is Nil. Furthermore, even if context[:controller] was accessible, I am not sure context[:controller].flash would be available. I worked on a plugin 6-8 months ago and don't think that worked (but I could be remembering incorrectly).
In order to work around that, I did:
module RedmineCerb4IssuesControllerPatch def self.included(base) # :nodoc: base.send(:include, InstanceMethods) end module InstanceMethods # make flash publically accessible so we can use it in our hooks def pflash flash end end
and was using context[:controller].pflash[:notice] with some success. My messages were getting added to the flash message. However, I seemed to have broken request/session encapsulation b/c the messages I added to flash seemed to hang around when other issues were saved.