Michael Stitt

Joined

1,250 Experience
0 Lessons Completed
1 Question Solved

Activity

Posted in Migrate away from Mandrill?

FYI I've been using SparkPost for a couple months now with no troubles. However, a couple weeks ago they suspended my account without notifying me. A user complained that the forgot password link was not working, I did some debugging and the code didn't change. I logged into their UI and found a very hard-to-notice flash message stating,

Your account has been suspended from sending. Please email [email protected] for help with your account

Mind you, all I do is send invitation and forgot password emails with this application. So, I emailed the Abuse department and got the following automated response:

Hello,

Thank you for your interest in SparkPost. We strive to offer the very best email service, and to that end, we maintain a strict anti-abuse messaging policy. The content of your messages is against our policies. To get good deliverability, messages must make their way through spam filters unscathed. Unfortunately, there is a high degree of abuse in your industry that makes it very difficult to deliver legitimate messages with similar content.

Because we cannot offer you the high deliverability you would expect from SparkPost, we must decline to provide our services. We wish you the best in your future business endeavors.

Respectfully,

The SparkPost Deliverability & Compliance Team

I responded to the email letting them know I think their algorithms are making a mistake. After getting no response I reached out to Customer Support and they said they'd look into. A couple days later I get the same automated response from the Abuse team.

After a couple different emails with Customer Support they eventually reactivated my account. With the exception of this event I've been happy with their service. Hopefully they'll fix these mistakes from happening.

Posted in Migrate away from Mandrill?

For those coming to this thread in the future, I decided to migrate to SparkPost. They have a great Mandrill Migration Guide, plus they offer 100,000 free emails per month!

I used Chris' screencast to setup Mandrill initially, so switching to SparkPost was easy as all I had to do was change a few of the parameters within the config/initializers/mail.rb file.

Posted in Migrate away from Mandrill?

Thanks, I'll checkout MailJet. I'm kind of leaning towards SendGrid since they offer a Free Tier (12k emails per month).

It looks like I'm not the only one scrambling to find an alternative: HN discussion

Posted in Migrate away from Mandrill?

You have a screencast where you describe how to incorporate Mandrill into your Rails application, and because of that I've used it in the last couple of apps I've built. I'm assuming you saw the blog post yesterday where the CEO of Mailchimp announced that you'll need to have a paid Mailchimp account in order to continue using Mandrill.

I only have one app in production which sends an invitation and password reset emails for an internal-only Rails app (serving ~20 users right now). I plan on pushing another application to production within the next month but that will likely not do more than 1,000 emails a month for the first couple months. I really liked that Mandrill offered a free tier to experiment and prototype with, so I guess I'm looking for another option similar to their previous offering.

I'm happy to pay for a transaction email service once I start consistently sending out thousands of emails but I'd rather not have to pay upfront for a service I'm most likely not going to use quite often. So, I'm writing to see if you plan to use a different service for transaction emails in future applications or if you have any other recommendations on Mandrill alternatives. Thanks!

Posted in validate presence of specific domain in email

I get that but I just wanted to point out in your Regex you're looking for .org and your error message says your looking for .com. So, if you're passing in .com email addresses it won't save that object because it doesn't pass your :email validation, which could be why it's not working.

Posted in validate presence of specific domain in email

Your code is looking for mydomain.org but your error message says mydomain.com. Is that causing the problem?

Other than that, if you don't want to use regex you could split the email string on the @ symbol and verify the last string in that array matches mydomain.com.

Posted in Saving _form along with has_many through items

Hi Chris,

I'm having difficulty wrapping my head around how to save a form (Kit) that includes optional items for a has_many through relationship (AmazonProductKit). Here are my models:

class Kit < ActiveRecord::Base
  has_many :amazon_product_kits
  has_many :amazon_products, through: :amazon_product_kits
end

class AmazonProduct < ActiveRecord::Base
  has_many :amazon_product_kits
  has_many :kits, through: :amazon_product_kits
end

class AmazonProductKit < ActiveRecord::Base
  belongs_to :kit
  belongs_to :amazon_product

  validates :quantity, presence: true
end

What I'd like to do with the Kits#_form is capture a couple Kit attributes (title, persons, and description) and then also allow the user to pick any AmazonProduct objects they'd like included in that Kit (this is how the form functions now, however, when I save it there are no AmazonProductKit objects being stored). I'd also like to have the ability to capture the quantity for each checked AmazonProductKit in a dropdown menu, but I haven't figured out how go about doing that.

So, I know I need to modify my controller and _form, I'm just not sure what exactly. Here's my kits_controller.rb:

class KitsController < ApplicationController
  before_action :set_kit, only: [:show]

  def index
    @kits = Kit.all
  end

  def show
  end

  def new
    @kit = Kit.new
  end

  def create
    @kit = Kit.create(kit_params)

    if @kit.save
      flash[:success] = "Kit has been created."
      redirect_to kit_path(@kit)
    else
      flash[:alert] = "Kit has not been created."
      render "new"
    end
  end

  private

    def set_kit
      @kit = Kit.find(params[:id])
    end

    def kit_params
      params.require(:kit).permit(:title, :persons, :description, :amazon_product_kits => [])
    end
end

And here's my kit _form.html.erb:

<%= form_for(@kit) do |f| %>
  <% if @kit.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@kit.errors.count, "error") %> prohibited this kit from being saved:</h2>

      <ul>
      <% @kit.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>


  <div class="field form-group">
    <%= f.label :title %><br>
    <%= f.text_field :title, required: true, autofocus: true, placeholder: "e.g. 72-hour Emergency Kit", class: "form-control" %>
  </div>
  <div class="field form-group">
    <%= f.label :persons %><br>
    <%= f.text_field :persons, autofocus: true, placeholder: "e.g. 1", class: "form-control" %>
  </div>
  <div class="field form-group">
    <%= f.label :description %><br>
    <%= f.text_area :description, rows: 10, autofocus: true, placeholder: "e.g. http://www.monkeysee.com/play/28716-orlando-s-newest-tourist-destination", class: "form-control" %>
  </div>

  <div class="field form-group">
    <%= collection_check_boxes(:kit, :amazon_product_kit_ids, AmazonProduct.all, :id, :title) do |b| %>
      <%= b.check_box %>
      <%= b.label %>
      <br>
      <!-- capture `quantity` of this AmazonProduct if checked -->
    <% end %>
  </div>


  <div class="actions form-group">
    <%= f.submit "Save Kit", class: "submit-button btn btn-default" %>
  </div>

<% end %>

Let me know if you think I should alter how I've constructed my model relationships or if I should consider tweaking how a new Kit is captured. Thanks in advance!

Posted in Deploy Multiple Rails Apps to Same DigitalOcean Droplet?

Sweet! I'll do that later today and let you know if I run into any hiccups.

Thanks again for producing great content on such a consistent basis!

Posted in Deploy Multiple Rails Apps to Same DigitalOcean Droplet?

I've used your guide to deploy a Rails app to a DO droplet -- which was extremely helpful! However, now I'm at the point where I'd like to take advantage of this existing droplet and deploy other Rails apps that I'm working on (mostly just landing pages at the moment).

Do you have any advice on how to go about this or can you point to any documentation implementing this? Are there any things I need to think about when sharing a VPS with multiple Rails apps?

Thanks!

Posted in API TOKEN DEVISE

Hi Ján,

Can you share your code on Github? I'm also trying to build a Rails API that uses Devise for user authentication.

Posted in Video Idea: Accepting Credit Card Payments

Sweet. Looking forward to this!

Posted in Video Idea: Accepting Credit Card Payments

Most web apps need the ability to accept payments from their users (whether they're automated monthly payments or just simple one time payments). It was such a easy process getting going as a Pro subscriber on GoRails, I'd love to see you walk us through how to do it with our own Rails app. I also think the "Account" page is very clean/uncluttered and I like how I can see my payment history.

I'm more interested in how I integrate a payment processor and accept payments than I am displaying a receipt. If you're not interested in making a video would you mind describing who/what you use to capture payments and any things I need to consider when implementing it myself?

Thanks!

Posted in New Users Only Created by Admin User

The devise_invitable gem was exactly what I was looking for! Thanks for the recommendation.

Posted in New Users Only Created by Admin User

I'm building an internal app for my company that contains data from various sources (e.g. web analytics, server logs, etc.). It's hosted on an EC2 instance with a DNS of "reports.example.com". Right now I have a security group on AWS that limits access to just my work IP Address, however, I'd like to be able to login from my phone and look at certain pages/reports.

In order to do that I'll have to force users to login, which I'm already doing (I'm using Devise for authentication and Pundit for authorization).

class ApplicationController < ActionController::Base
  before_action :authenticate_user!
  ...
end

However, if I remove the IP constriction a random person can still find the URL and sign up. So, my question is how do I make it so that only I (or any admin) can create a new user, and then when they login for the first time they are prompted to create a new password?

I'm planning on building a building a page (/admin/users) that lists each user and allows me to activate/deactivate the account, as well as add a new user to the system.

I guess I'm just curious how to limit the registration of new users unless an admin creates it. Any advice is appreciated!

Thanks for the heads up! I successfully installed my SSL cert on my Production environment. I'm now going to attempt to install a self-signing cert on my Staging environment, so that I don't need to buy another cert -- tried using my Production cert but the domain name didn't match so it threw an error.

Thanks again for all of your help!

If I open up a New Private Window in Firefox and type 'gorails.com' into the URL bar I end up at http://gorails.com/ (I can't see the http:// part of the URL, I have to select all and copy/paste it into a text editor). I then clicked on the Forums link and copy/pasted the URL into a text editor and saw that the URL was http://gorails.com/forum. So, it looks like I'm accessing your site over http.

I just received my SSL cert from Namecheap and I'm going to give it a shot installing it on my droplet -- wish me luck!

One quick question - do you a staging environment (different server/domain/subdomain/etc.) to test code deployments before pushing it into production?

Thanks for the quick response! I'm trying to decide if I should force all traffic over https (which I want to do) and how I should go about it (using Rails config.force_ssl = true or redirect it from within Nginx. I notice you allow both (at least http when I'm not logged in), is by design? Any advice is much appreciated.

Thanks!

Your tutorial on configuring a VPS on DigitalOcean for a Rails app is great! This came in super handy while I was creating mine!

Can you explain to me the steps you took to create and install an SSL certificate as well?

Posted in Implementing Markdown Support in Forums

Ahh, I didn't notice it because I was looking for the title of the video to be prefixed with "Forum Series Part X". I'll watch it now, thanks!

Posted in Implementing Markdown Support in Forums

I ended up using Redcarpet to provide Markdown support in my forums. Here's my markdown() helper function, if you're also using Redcarpet let me know if there are any configurations/extensions I should consider using:

def markdown(text)
      render_options = {
        # will remove from the output HTML tags inputted by user 
        filter_html:     true,
        # will insert <br /> tags in paragraphs where are newlines 
        # (ignored by default)
        hard_wrap:       true, 
        # hash for extra link options, for example 'nofollow'
        link_attributes: { rel: 'nofollow', target: '_blank' }
        # more
        # will remove <img> tags from output
        # no_images: true
        # will remove <a> tags from output
        # no_links: true
        # will remove <style> tags from output
        # no_styles: true
        # generate links for only safe protocols
        # safe_links_only: true
        # and more ... (prettify, with_toc_data, xhtml)
      }
      renderer = Redcarpet::Render::HTML.new(render_options)

      extensions = {
        #will parse links without need of enclosing them
        autolink:           true,
        # blocks delimited with 3 ` or ~ will be considered as code block. 
        # No need to indent.  You can provide language name too.
        # ```ruby
        # block of code
        # ```
        fenced_code_blocks: true,
        # will ignore standard require for empty lines surrounding HTML blocks
        lax_spacing:        true,
        # will not generate emphasis inside of words, for example no_emph_no
        no_intra_emphasis:  true,
        # will parse strikethrough from ~~, for example: ~~bad~~
        strikethrough:      true,
        # will parse superscript after ^, you can wrap superscript in () 
        superscript:        true,
        # will require a space after # in defining headers
        space_after_headers: true
      }

      Redcarpet::Markdown.new(renderer, extensions).render(text).html_safe
    end
logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.