I've created a demo of my program. The demo is used to present the program to the customers. Before each presentation I want to reset the db, and insert certain data, the actions that I have to do are:
rake db:drop
rake db:setup
rake db:seed:demo
But they are not always me to present it and others do not use the console, so I wanted to put in the settings page the ability to reset via a button.
I tried in this way:
module SettingsHelper
require 'rake'
def reset
Rake::Task[db:drop].invoke
Rake::Task[db:setup].invoke
Rake::Task[db:seeds:demo].invoke
end
end
I put in the form:
<%=button_to "Reset", reset, class:"btn red" %>
But I can not drop the database with the active server ... how can I do?