flash[:notice]
gets erased as soon as I use redirect_to
in rails 2.2.2
It's a super simple ruby application, so it shouldn't be to hard to find what's going on (although, I couldn't find it obviously...)
My routes.rb looks like this
resources :happenings
root to: "happenings#index"
post "/happenings/save"
And my HappeningsController looks like this
def index
@happenings = Happening.all
end
def save
flash[:notice] = "saved"
redirect_to root_path
end
Now if I'm debugging and I add puts flash[:notice]
to the save action, it will print "saved" to my terminal
if I add `puts flash[:notice] to the index action, it will print an empty line to the terminal. So it obviously has been erased by the time the index action gets executed.
Any ideas? Thanks a lot?
Edit, Here's a bit more information.
The save
action get's called by a form
<form method="post" action="/happenings/save">
The following is the server's output when I submit a form (and request the save action)
Started POST "/happenings/save" for 127.0.0.1 at 2015-07-02 23:16:31 +0200
Processing by HappeningsController#save as HTML
Parameters: {"happening_name"=>"Test happening", "happening_time"=>"2015-07-24T13:15"}
Can't verify CSRF token authenticity
Redirected to http://localhost:3000/
Completed 302 Found in 1ms (ActiveRecord: 0.0ms)
Started GET "/" for 127.0.0.1 at 2015-07-02 23:16:32 +0200
Processing by HappeningsController#index as HTML
Rendered happenings/index.html.erb within layouts/application (0.1ms)
Completed 200 OK in 32ms (Views: 28.4ms | ActiveRecord: 0.0ms)