ruby - Can't get Sinatra Flash Gem to work -
i trying flash notice appear after successful submission of form. in rails utilize in controller:
:notice => "youve submitted form"
i came across sinatra flash gem , display flash message after redirect. installed gem , setup so:
myapp.rb:
require 'sinatra/flash' enable :sessions #form config )} redirect '/success' # hook after form submission end get('/success') flash[:success] = "thanks email. i'll in touch soon." erb :index end
all happens redirected index page no flash message. looking @ docs can see need do. see different?
i moved flash notice before redirect save message:
flash[:notice] = "thanks email. i'll in touch soon." redirect '/success' get('/success') erb :index end
then, in view, placed @ top now:
<div id='flash' class='notice'> <a class="close" data-dismiss="alert">×</a> <%= flash[:notice] %> </div>
it needs styling works. if has improve solution please share.
ruby sinatra alert
No comments:
Post a Comment