# Wbase (w1zebase) A base for building SAAS the w1zeman1p way... By the numbers Includes: + Auth + Users controller + Userable helper module for common user stuff + Sessions + Password resets + Landing page (via config) + LetsEncrypt + Stripe subscriptions + Drip email campaigns + Mail template + Mail Event Tracking (click, open etc.) Requires: `User` model with... + `password_digest` + `email` + `session_token` + `reset_token` + `selected_plan` (stripe id of a plan the user will be on after trial) + `login_at` Kickstart ```sh rails new APPNAME -T --database=postgresql -j --skip-turbolinks hub create APPNAME heroku apps:create APPNAME ``` Generate with: ```sh rails g model User email:string:index password_digest session_token:string:index reset_token login_at:datetime root:boolean:false ``` Setup heroku like this: ```sh heroku addons:create papertrail heroku addons:create newrelic heroku addons:create scheduler heroku addons:create sendgrid heroku addons:create rollbar heroku addons:create rediscloud heroku addons:create ssl:endpoint ``` Domain stuff ```sh heroku domains:add DOMAIN sudo certbot certonly --manual sudo heroku certs:add /etc/letsencrypt/live/DOMAIN/fullchain.pem /etc/letsencrypt/live/DOMAIN/privkey.pem # Later on... sudo heroku certs:update /etc/letsencrypt/live/DOMAIN/fullchain.pem /etc/letsencrypt/live/DOMAIN/privkey.pem ``` Add this to production.rb: ```rb # S3 Stuff config.paperclip_defaults = { :storage => :s3, :s3_credentials => { :bucket => ENV['AWS_BUCKET'], :access_key_id => ENV['AWS_ACCESS_KEY_ID'], :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'] }, :s3_region => ENV['AWS_REGION'] } # Tagged logging STDOUT.sync = true require 'rollbar/logger' Rails.logger = if defined?(ActiveSupport::TaggedLogging) ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) else Logger.new(STDOUT) end Rails.logger.level = 1 Rollbar.preconfigure do |config| config.logger = Rails.logger end # Emailing config.action_mailer.default_url_options = {host: '!!!CHANGEME!!!'} ActionMailer::Base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => ENV['SENDGRID_USERNAME'], :password => ENV['SENDGRID_PASSWORD'], :domain => 'heroku.com', :enable_starttls_auto => true } ``` Setup `config/initializers/wbase.rb` with these options: ```rb Wbase.setup do |config| config.site_name = "ShortName" config.title = "Juicy SEO Title" config.description = "witty description" config.url = "https://www.domain.com/" config.image = "/logos/color-logo-128x128.png" config.keywords = "buzzword, buzzword, buzzword" config.admin_email = "admin@domain.com" config.firehose_email = "firehose@domain.com" config.getting_started_video = 'https://www.youtube.com/embed/elP2kTZXMME?list=PLHQBWWPXnPNzH22p0dMk_kkbP6t_-KXu8' # Landing page jumbotron config.sub_title = "Tools to help you LuLaRoe like a Boss!" config.call_to_action = "Start Today" config.call_to_action_path = "/user/new" config.primary_color = '#F67599' config.success_color = '#64CCC9' config.info_color = '#8BB8E8' config.warning_color = '#DD7FD3' config.danger_color = '#FF9D6E' config.about_view = false config.testimonials = [ ['-- CJ', '/images/cj.jpg', 'Want to leave a testimonial here? Let me know! :)'] ] config.team = [ ['CJ Avilla', 'DEVELOPER', '/images/cj2.jpg'], ] # Landing page nav config.nav_items = [ ['Pricing', '#pricing-section'], ['Sign Up', '/user/new'], ['Log In', '/session/new'], ] # Landing page social links config.socials = [ ['Facebook', 'fa fa-facebook', 'https://www.facebook.com/roemeapp'], ] # Landing page features config.features = [ ['Statistics', "See how many items you've sold by week, know how much you need to buy to meet minimums for Trainer.", 'fa-line-chart'], ] config.case_studies = [ ['Facebook Sales', 'Upload photos of your inventory and post to Facebook groups / albums based on style and size. Customers can claim items and even say they want to be next in line for a sold item!', '/images/facebook1.png'], ] config.plans = [ ['Starter', '5', '/user/new?plan=consultant', 'per month', '14 day free trial', ['Unlimited Imports', 'Unlimited Customers', 'Email Support', 'Facebook Integration', 'Build / Bless Integration']], ] end ``` `config/application.yml` ```yml development: STRIPE_API_KEY: STRIPE_PUBLISHABLE_KEY: DRIP_API_TOKEN: '' DRIP_ACCOUNT_ID: '' production: STRIPE_API_KEY: STRIPE_PUBLISHABLE_KEY: DRIP_API_TOKEN: '' DRIP_ACCOUNT_ID: '' AWS_ACCESS_KEY_ID: '' AWS_SECRET_ACCESS_KEY: '' AWS_BUCKET: '' AWS_REGION: 'us-east-1' ``` `Gemfile` ```rb gem 'wbase' # IF doing AWS gem 'paperclip', '~> 5.0.0' gem 'aws-sdk', '~> 2.3.0' ``` install migrations... ```sh rake wbase:install:migrations ``` `config/routes.rb` ```rb if Rails.env.development? mount RailsAdmin::Engine => '/ad', as: 'rails_admin' end mount Wbase::Engine => '/', as: 'wbase' ``` Sendgrid settings: 1. Go to https://app.sendgrid.com/settings/mail_settings 2. Turn on Event Notification 3. Set HTTP POST URL to `https://www.domain.com/mail_events`