How to send on a render your message from the controller hook? something like flash [: error] = "Message". <- With this method does not work, redmine falls from 500.
Hook
module Integration class ControllerIssuesNewBeforeSaveHook < Redmine::Hook::ViewListener def controller_issues_new_before_save(context={}) # Получаем данные из формы project_id = context[:issue].project.custom_field_values[0].value.to_i if (project_id == 0 || project_id.blank?) flash[:error] = "Error" # Пока всё упадет с 500 redirect_to :back end end end end Mistake
NameError (undefined local variable or method flash' for #<Integration::ControllerIssuesNewBeforeSaveHook:0x0000000410b298>): plugins/integration/lib/integration/controller_issues_new_before_save_hook.rb:16:incontroller_issues_new_before_save' lib/redmine/hook.rb:61:in block (2 levels) in call_hook' lib/redmine/hook.rb:61:ineach' lib/redmine/hook.rb:61:in block in call_hook' lib/redmine/hook.rb:58:intap' lib/redmine/hook.rb:58:in call_hook' lib/redmine/hook.rb:91:incall_hook' app/controllers/issues_controller.rb:139:in create' lib/redmine/sudo_mode.rb:63:insudo_mode'
flashusecontext[:flash]? - D-side[]=' for nil:NilClass): находил подобный вариант: context[:controller].flash[:notice] << 'something to append to the flash message' но в этом случае кидает: NoMethodError (undefined method<< 'for nil: NilClass): - Ravil["notice"]instead of[:notice]needed? - D-side