Feature #6383

modifying flash from model hooks

Added by Randy Syring about 10 years ago. Updated almost 10 years ago.

Status:NewStart date:2010-09-13
Priority:LowDue date:
Assignee:-% Done:

0%

Category:Plugin API
Target version:-
Resolution:

Description

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.

History

#1 Updated by Eric Davis about 10 years ago

(I asked Randy Syring on IRC to open this as a reminder for me. The assignment is valid.)

#2 Updated by Eric Davis almost 10 years ago

  • Assignee deleted (Eric Davis)

I am stepping down from working on Redmine. If someone else is interesting in working on this issue, feel free to reassign it to them.

Eric Davis

Also available in: Atom PDF