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.