26.1 Active Merchant 25.1 rack
implement a custom rake task
edit lib/tasks/db_backup.rake
namespace :db do
desc "Backup the production database"
task :backup => :environment do
backup_dir = ENV['DIR'] || File.join(Rails.root, 'db', 'backup')
source = File.join(Rails.root, 'db', "production.db")
dest = File.join(backup_dir, "production.backup")
makedirs backup_dir, :verbose => true
sh "sqlite3 #{source} .dump > #{dest}"
end
end
rake db:backup
mkdir -p /home/rubys/git/awdwr/edition4/work-192/depot/db/backup
sqlite3 /home/rubys/git/awdwr/edition4/work-192/depot/db/production.db .dump > /home/rubys/git/awdwr/edition4/work-192/depot/db/backup/production.backup
cleanup (for HAML)
edit app/views/store/index.html.erb
remove scaffolding needed for standalone operation
edit app/store.rb
class StoreApp
def call(env)
x = Builder::XmlMarkup.new :indent=>2
x.declare! :DOCTYPE, :html
x.html do
x.head do
x.title 'Pragmatic Bookshelf'
end
x.body do
x.h1 'Pragmatic Bookshelf'
Product.all.each do |product|
x.h2 product.title
x << " #{product.description}\n"
x.p product.price
end
end
end
response = Rack::Response.new(x.target!)
response['Content-Type'] = 'text/html'
response.finish
end
end