0

I made a mistake before migrating a plugin, and have written

flash[:notice] = :label_presta_added

instead of

flash[:notice] = l(:label_presta_added)

I corrected my mistake but it seems that my Redmine Plugin has trashed my Redmine. Even though I delete my plugin a migrate once again, I still get this error:

    Started GET "/" for 127.0.0.1 at 2016-06-01 22:21:37 +0200
Processing by WelcomeController#index as HTML
  Current user: admin (id=1)
  Rendered welcome/index.html.erb within layouts/base (28.1ms)
Completed 500 Internal Server Error in 366ms (ActiveRecord: 116.0ms)

ActionView::Template::Error (undefined method `html_safe' for :label_presta_added:Symbol
Did you mean?  html_safe?):
     97:     <div id="sidebar">
     98:         <%= yield :sidebar %>
     99:         <%= view_layouts_base_sidebar_hook_response %>
    100:     </div>
    101: 
    102:     <div id="content">
    103:         <%= render_flash_messages %>
  app/helpers/application_helper.rb:312:in `block in render_flash_messages'
  app/helpers/application_helper.rb:311:in `render_flash_messages'
  app/views/layouts/base.html.erb:100:in `_app_views_layouts_base_html_erb__4104276684161420982_39604440'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

Can somebody give me a hand here? Thanks in advance!

Michael Gaskill
  • 7,913
  • 10
  • 38
  • 43
djcaesar9114
  • 1,880
  • 1
  • 21
  • 41

3 Answers3

0

Have you restarted the server? Or you can use flash[:notice] = nil to remove it.

Kieran E
  • 3,616
  • 2
  • 18
  • 41
  • First I changed to **flash[:notice] = 'test'** Then I deleted the plugin. After every change, I did: **rake redmine:plugins:migrate RAILS_ENV=production** and **/etc/init.d/apache2 restart** – djcaesar9114 Jun 01 '16 at 20:48
  • @djcaesar9114 Are you making these changes on a live site? If so, you're playing a dangerous game. Anyway, what Rails server are you using? Passenger, Unicorn, Puma, Webrick, etc,. I mean restarting that service. That should do it. – Kieran E Jun 01 '16 at 21:03
  • I don't know what you mean with "a live site". I'm developing a Redmine Plugin, and I have a Redmine working on my computer, the Redmine I'm testing the plugin with. I restarted passenger, but I still get the same error :( – djcaesar9114 Jun 01 '16 at 21:06
0

This is stored in your session, so usually changing the session secret key will invalidate all sessions and discard any old session data.

You can also try and rescue to clear it out as a one-time deal.

tadman
  • 208,517
  • 23
  • 234
  • 262
  • OK great, changing the session secret key did solve my problem. However, I really don't understand why this problem appear... – djcaesar9114 Jun 01 '16 at 21:30
  • That value persists in your session until a page is successfully rendered. Since you kept getting an exception it could never run to completion. – tadman Jun 01 '16 at 21:32
  • OK. But now when I change the value of **flash[:notice]**, it won't change. I'm a beginner in Rails (I come from PHP), so it means I have to change the session token every time I make a change in my code? Thanks anyway :) – djcaesar9114 Jun 01 '16 at 21:37
  • No, the value will change *if* the request can be completed. The session update occurs at the end of the request. Clearing sessions should only be necessary if you really mess something up, like you have here. – tadman Jun 01 '16 at 21:37
  • OK, I understand now. Rails really is different from PHP! Thanks a lot, tonight I'll be able to sleep now. – djcaesar9114 Jun 01 '16 at 21:48
  • By default Rails stores the session data in a cookie, and a cookie is only updated when the request completes. PHP stores the session ID in the cookie and the rest on disk but if you like Rails can also operate this way. The default is safer for multi-server installations. – tadman Jun 01 '16 at 21:51
0

It looks like it throws a html_safe error. Can you see if the method which is rendering the flash is using html_safe? It looks like its coming from there.

Not sure exactly, may be shooting in the dark. But read these and try may be:

actionview::template::error(undefined method 'html_safe' for nil:NilClass)

http://www.redmine.org/issues/8477

Community
  • 1
  • 1
tanvir2362
  • 76
  • 10
  • Actually this html_safe error comes from the fact that it looks for a value I don't have anymore (:label_presta_added). And what I don't understand is where does Rails find this value, whereas I erased it from my code. Apparently some data is stored in the sessions. – djcaesar9114 Jun 01 '16 at 21:45
  • Yes, I understood that. Thought restarting the server should have cleared the session, so I thought may be you will have to remove html_safe from that method and try again. But apparently the session was never cleared. Good that your problem is solved. :) – tanvir2362 Jun 01 '16 at 21:53