Guest User

Untitled

a guest
Jun 20th, 2018
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. mkdir wpgskeeter
  2. cd wpgskeeter
  3. git init
  4. heroku create wpgskeeter
  5. git add .
  6. git commit -m 'Initial commit'
  7.  
  8. Create a .gems file:
  9. sinatra
  10. nokogiri
  11. compass
  12. rdiscount
  13. activerecord
  14. activerecord-postgres-adapter
  15.  
  16.  
  17. Create a config.ru file:
  18. require 'sinatra_main'
  19. run Sinatra::Application
  20.  
  21. Command line:
  22. heroku console
  23. ENV['database_url']
  24.  
  25. Create a config/database.yml file:
  26. production:
  27. encoding: unicode
  28. adapter: postgresql
  29. port: 5432
  30. host: 'host'
  31. database: 'db'
  32. username: 'user'
  33. password: 'pass'
  34.  
  35. Create a sinatra_main.rb file:
  36. require 'sinatra'
  37. require 'nokogiri'
  38. require 'sass'
  39. require 'haml'
  40. require 'compass'
  41.  
  42. ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))['production'])
  43.  
  44. get '/' do
  45. "Hello World!"
  46. end
  47.  
  48. Command line:
  49. heroku addons:add cron:daily
  50. heroku addons:add sendgrid:free
  51.  
  52. Create your Rakefile:
  53. task :environment do
  54. require 'active_record'
  55. require 'pony'
  56. ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))['production'])
  57. end
  58.  
  59. namespace :db do
  60. desc "Migrate the database"
  61. task(:migrate => :environment) do
  62. ActiveRecord::Base.logger = Logger.new(STDOUT)
  63. ActiveRecord::Migration.verbose = true
  64. ActiveRecord::Migrator.migrate("db/migrate")
  65. end
  66. end
  67.  
  68. task :cron => :environment do
  69. Pony.mail(:to => 'stungeye@gmail.com',
  70. :from => 'me@example.com',
  71. :subject => 'hi',
  72. :body => 'Hello there.',
  73. :via => :smtp, :via_options => {
  74. :address => 'smtp.sendgrid.net',
  75. :port => '25',
  76. :authentication => :plain,
  77. :user_name => ENV['SENDGRID_USERNAME'],
  78. :password => ENV['SENDGRID_PASSWORD'],
  79. :domain => ENV['SENDGRID_DOMAIN']}
  80. )
  81. end
  82.  
  83.  
  84. Test out the cron manually from the command-line:
  85. heroku rake cron
Add Comment
Please, Sign In to add comment