Chris Oliver

Joined

291,480 Experience
86 Lessons Completed
296 Questions Solved

Activity

Posted in How do I add opensearch to a Rails app

That's a great question. I've never intentionally added that feature to GoRails, so I don't actually know. :-) In fact, I don't think there's any OpenSearch tags or anything so I wonder if they can detect a standard like /search url or something in my case.

Posted in What are your goals for 2018?

Hey Alan! Glad you started this again. I love doing these.

2017 was really good. I launched HatchBox.io and having my second product up and running has been fantastic experience.

For 2018, my goals are:

  1. Launch a 3rd product to help small businesses get started (I'll be announcing this soon!)
  2. Grow GoRails & HatchBox.io
  3. I want to explore Crystal Lang a lot more and see about building a new web framework with it

Hey Tatiane,

You can do this pretty easily with an after_create callback on the StockFlow model.

Roughly, it'd probably look something like this:

class StockFlow
  after_create :update_stock

    def update_stock
      stock = Stock.find_by(name: name)

        if stock.present?
        case in_out
        when "in"
              stock.update(amount: stock.amount + amount)
          when "out"
              stock.update(amount: stock.amount - amount)
            end

        else
          Stock.create(name: name, amount: amount, kind: kind)
        end
    end
end

Posted in Rails & Vue.js Trello Clone - Part 2 Discussion

I used a thick arrow function which does that for you. You'll see my success function is: "success: (data) => {" and you use "success: function()".

Pretty much exactly what you mentioned. I am working on a video app that I'll be showing off more in the future, but it has a bunch of videos on the page and I wanted to use a Vue app for each one. I just selected all the elements that matched like ".video" and then looped over them and created a new Vue() app for each one. Works like a charm.

You won't need to check if the element exists in this case because it won't run the loop if there are no results so it may be a little more straightforward than selecting by ID which could return you null (and and why we have to check it).

Posted in Rails & Vue.js Trello Clone - Part 1 Discussion

AJAX will always be slower because you're making a second network request and will always force a 'loading' state on the Vue app. I personally hate waiting for widgets to load so I'd rather preload the JSON on the page and have an instantly available frontend.

Posted in Hatch Deploy

You have to setup domains for your apps otherwise your server doesn't know which app to serve and will always just serve the first one.

Posted in Two-factor Authentication

Posted in Using Webhooks with Stripe Discussion

Actually, stripe_id on the User model references a Stripe::Customer's ID and stripe_id on a Charge references a Stripe::Charge's ID. That's a great point to clarify!

We're just storing references to the different objects in Stripe so we can load up those objects whether they're a Customer, a Charge, or a Subscription, etc.

Posted in Carrierwave file extension issue

In that case, you're gonna want to change your method for the filename to use .jpg instead of the original extension:

  def filename
    "#{secure_token}.jpg" if original_filename.present?
  end

You might want to add a conditional to do this only for a specific version (the one that you converted to jpg) and use the original extension as necessary for the rest.

Posted in Carrierwave file extension issue

What is your issue?

You have it set to only allow png's:

  def extension_whitelist
      %w(png)
  end

Posted in Passing name objects to Stripe

Hey Charles,

I'm pretty sure you want the description attribute and you can pass the user's name in there. https://stripe.com/docs/api/ruby#create_customer-description

If you write your Javascript using webpacker, it will use ES6 out of the box.

For the asset pipeline, there's a sprockets-es6 gem.

Posted in Error Tracking with Errbit Discussion

It asks for your repo so it can link you to the line of code that triggered the error.

And yes, any errors from environments mentioned in ignore, will be skipped.

Posted in Why is viewer_id 0 on every video?

You'll want to make sure you have your association setup for it

class Video
  belongs_to :viewer, class_name: "User"
end

And then your view can use that association to load the email:

<%= @video.viewer.email %>

Posted in Why is viewer_id 0 on every video?

Hey Michelle,

At a quick glance, you're setting the viewer_id in your form (which is a database integer column) but your form is submitting email addresses. You probably want to display email address but submit the value as the user's ID instead.

<%= f.select :viewer_id, options_for_select(@users.map{ |u| [u.email, u.id] })), class: 'form-control'  %>

If you pass in an array for each user of email and id like this example, it should show the email in the form field, but the ID will be the value actually submitted to the server. That should assign the correct value for you then instead of 0.

Posted in Different Notification Types By Type

I imagine they go through most of it, and then just schedule a background job to notify via mobile if it hasn't already been marked as sent. I'm not sure what their delay is but it's like 3 minutes or something for mobile.

Posted in Different Notification Types By Type

Someone at Slack posted this flowchart of the rules used to determine whether or not to send a notification:


Posted in Payments with Stripe Master Class

I would probably just install the Heroku CLI on Windows as well to solve that problem. Then you can access that from Windows until it's finally stable to run on the Linux subsystem.