Chris Oliver

Joined

292,970 Experience
93 Lessons Completed
295 Questions Solved

Activity

If you ask for JS back and you're using Turbolinks, it will actually send back a Turbolinks.visit() to redirect you on success which is awesome and means everything is handled like a single page app. You still have to handle the JS side for failure, but there's some talk about having that automated as well with some changes to Turbolinks to replace the current page with the standard re-render on failure. For now you have to just insert errors on the page manually.

You can always just grab the url from the wrapper form. The reason I didn't do that in these episodes was the rails_ujs library was doing something weird with the button clicks and so I left it out. Normally I would just use Rails to render a form tag and then use Vue to make it work, so then on submission Vue can just simply grab the url from the form (and csrf token too).

In that situation, I would probably just leave the JSON alone, serialize it with the wrong names, and then at the very end go through and rename those properties. You could do that on either side as well, in the JS or in the controller. It wouldn't really matter, but it might be easiest to do in JS.

Posted in The Params Hash | GoRails

You know, I don't believe I ever got around to it. Going to record it this week.

Posted in Subscriptions with Stripe Discussion

Thanks for the reminder, I have been planning on doing a new episode covering the new Stripe Elements JS library. It seems a little less clear than the old version at a first glance, but I haven't implemented it just yet.

Posted in Hatch: Deploying my first App

Hmm! I guess probably since you tested it earlier on I probably fixed some of the bugs around the Bitbucket stuff. I will wait until another report of that issue and see if it's a consistent thing or not. :)

If you run into any other issues, just ping me and I'll make sure it gets all fixed up.

Posted in Extending Rails flash

Hey Jiri,

Do you know for sure if that file is being loaded? I think that it should be since it's in app, but I would just want to verify that.

You can also just simply define this in an initializer if you want a simpler way of doing this. It would look something like this:

# config/initializers/flash.rb

class ActionDispatch::Flash::FlashHash
  def my_method
    #...
  end
end

And last question, what's the goal you're trying to accomplish with this?

Posted in Hatch: Deploying my first App

Haha! Perfect. Only you and the internet will know. ;)

Trying to think why that happened. Did you add your Bitbucket account after your server was provisioned?

Posted in Hatch: Deploying my first App

I just manually re-ran the add SSH key script on your server. You should see the server's SSH key in your bitbucket account now at https://bitbucket.org/account/user/USERNAME/ssh-keys/

Was doing support and accidentally posted as the wrong account in case you saw the email notification from the wrong user. ;)

Hey Stan,

You mean a code example for the all-day events?

Posted in Deploy Ubuntu 16.04 Xenial Xerus Discussion

Meant to reply sooner, but all your ssh keys are located in ~/.ssh so you can backup that folder and just replace it on your new install to use the same keys.

Posted in iTunes Controller Code Review: Part 3 Discussion

Alrighty, source code is posted now! https://github.com/gorails-...

Also included some extra refactoring and goodies like a "help" command and a "url" command to open a url in Safari.

Posted in Direct File Uploads to S3: Part 2 Discussion

Thanks Shawn! 🤘

Posted in Hatch: Deploying my first App

So two things here:

  1. Did Hatch successfully add an SSH key to your BitBucket account? I've had a ton of trouble with their API on this.

Hatch generates a key for your server so it can check out your code and that way it doesn't have to know your personal SSH key either when it clones your repo.

  1. You have to add your SSH key to the server with the SSH Keys tab in the UI so you can SSH in. By default, there aren't any keys on the server, so you won't be able to login until you do that.

You can also add the SSH key to your account which will be pre-installed on all the new servers you setup as well for convenience. You'll still have to add it to the already created server individually though.

Posted in iTunes Controller Code Review: Part 3 Discussion

Yeah I'm going to upload it as long as I get permission from the original author. :)

Haha! Yeah no worries man. Calendars get tricky at a point when you're doing all day events and so on.

The main thing to understand here is that simple_calendar is just sorting the objects you give it by the time attributes, so they must all have valid times and dates. All-Day events should sort to the top, which means their start time should always be 12:00am. If that is nil or some other value in the database, they will sort nil or those other values and will be incorrectly placed.

Since it does the sorting internally, any pre-sorting you might have done will be ignored. Your all-day sort to the top is going to be ignored since simple calendar can't know ahead of time which day to place the event. As long as you get your times right for each event, simple calendar will take care of the rest.

Posted in Multiple Devise Users sharing a dashboard

Hey Stephen,

I would just make a custom before_action:

before_action :authenticate_company_or_contractor!

def authenticate_company_or_contractor!
  redirect_to root_path, alert: "You aren't allowed to do that" unless company_signed_in? || contractor_signed_in?
end

And voila. You're done. This is basically the exact same thing that authenticate_user! (or company or contractor, etc) implement behind the scenes. Nothin fancy!

Ah ha! That would explain it. :) Should have asked about that, but I assume that people are using the latest too quickly sometimes.

You have two options for that:

  1. I would just do like I showed in the episode by creating your virtual array of events for recurring ones. The all-day events you would want to handle a little differently and to actually be passed into simple_calendar with the start time as 12:00am and 11:59pm for the end time. No overriding necessary as these will obviously be sorted to the top automatically. Actually, if the user checks the "all day" box you can just save those values in the database and then you don't have to do any special code for them.

  2. You could override the method. Just redefine the calendar object and override that method. Generally not a great idea as you may run into problems when the gem gets updated in the future.

It definitely works. Just tested a fresh install of simple_calendar and both month_calendar and week_calendar that I tested work as expected. https://cl.ly/kW2w One record in the database but it gets rendered 4 times, one for each day it spans.

That means that your start_time and end_time attributes must be the culprit in your last example I guess. What do your records look like?