0

I want to display to user a flash/alert with proper info about the result of saving to database. I'm building a simple Sinatra app with Twitter bootstrap. ORM of choice is DataMapper and template language is HAML.

This is the POST method used for registering device in database:

post '/register' do
  @device = Device.new( :id       => params[:id],
                        :owner    => params[:owner],
                        :os       => params[:os])

  if @device.save
    puts "Saving device to database - SUCCESS"
    redirect '/'
  else
    puts"Saving device to database - FAILURE"
    redirect '/'
  end
end

As you can see, now I'm redirecting to the root path but I want to display in current view alart with this message.

cojoj
  • 6,405
  • 4
  • 30
  • 52

1 Answers1

0

What you describe sounds like Sinatra::Flash

This save your message in a session and show it on your page (your layout file).

Sir l33tname
  • 4,026
  • 6
  • 38
  • 49