Chris Oliver

Joined

293,020 Experience
93 Lessons Completed
295 Questions Solved

Activity

Posted in macOS sierra working w/ Ruby / Rails / RBENV?

I believe as long as most of the Homebrew issues for Sierra are sorted and you've got Xcode 8's command line tools installed it should be good. I haven't upgraded yet either, but plan to do that on my laptop once the official release is out.

Pretty sure some other people have tried it here so hopefully they'll weigh in!

Posted in Using Vagrant for Rails Development Discussion

Since we're using rbenv, it should compile Ruby instead of downloading it as a binary. You should be able to change the version numbers, although I haven't tried it with 2.3.1 yet.

Posted in How to setup SSL with a rails app

Hey Francisco,

Heroku has a free beta SSL offering that you can use (rather than the normal $20/mo to use SSL): https://devcenter.heroku.com/articles/ssl-beta

I believe you just need to use the command line to upload your certs and you should be good to go!

Absolutely! I like trying to show how to use a gem as well as showing how you could build your own version from scratch. It makes using any library a lot less daunting when you know you could go in and fix it yourself if you wanted. :)

Got any suggestions you'd like to see?

Posted in Deploy Ubuntu 14.04 Trusty Tahr Discussion

Thanks Mike. Doing my best to keep it updated! :D

Posted in How do i save a field in a separate table?

Hey Alan,

That's a pretty good way of doing it. The logic is that if a user isn't connected to a brand, then don't allow them to edit. The current_user.brands.find actually uses the join table because you're using the association. The only thing you'd need to access current_user.user_brands directly for would be if you were to add and check for roles on that table. Without roles, you can assume that if the role exists, then the user has access to that brand.

Posted in File Uploading with Carrierwave Discussion

Easier said than done, but I have been coding for over 10 years (I started in 7th grade). My routine is usually trying something new at least a few times a week, hopefully daily. I also often try new technologies and compare them to what I know and try to recreate something I know with that. Like React Native vs iOS native swift code for example. Or Python vs Ruby or Django vs Rails. The comparisons help because they give you insight into why the language or framework creators chose to do things the way they did. I'll often read the source code for other apps, but usually it comes down to applying it on a real project. That's why I've got 188 open source repositories on my github. :) https://github.com/excid3?t...

I should do an actual episode on this topic or something. Any specific questions you think would be helpful to answer about my learning method?

Posted in File Uploading with Carrierwave Discussion

So I unfortunately didn't do a great job of including the source code or the steps before the examples here. I've been doing a much better job of that lately. Basically this app just had a model called Book which was a scaffold that has a title column and description column. I also added Bootstrap to make it look pretty, but that's not necessary. That should be all you need. I am revamping the site to organize everything in series so you can watch all the related episodes together, but some of these early episodes only focused on a specific piece and didn't include all the setup instructions unfortunately.

Posted in Realtime Notifications with ActionCable Discussion

You need to have Redis installed and running. If you're on a Mac, "brew install redis" assuming you have Homebrew.

The attr_reader makes it so you don't have to reference the instance variable. "to: customer" points to the attr_reader, allowing you to go swap that out at some point with some other type of reference in the future if you wanted, rather than an instance variable which is useful for future potential refactoring since a attr_reader or function called "customer" would look exactly the same.

Glad I can help, even if it's slow goin' for a bit. Do this a few times and you'll get really comfortable debugging these more complicated processes and be doing them often in no time! :)

And believe me...I've probably wasted months or more of my life to debugging all the various things over the years...

I guess one thing also to note is that since the record hasn't been saved, it won't be able to set the Booking ID in the Stripe description until after the record saves. Maybe initiate an update to store the booking ID reference on there after the save is a better plan.

Ah yup! That is probably it. Since you're inside the instance rather than the controller you can just reference it as stripe_token. And the same with all the other references.

Inspect all the steps in the reserve method and print out the calculations and such. There's probably a piece in there that's not correct and needs a little fixing. You can use byebug to play with those calculations interactively which I find to be super helpful for debugging.

Well, so you don't need that anymore because you said you've already got your database defaulting the column to 0. 👍 Free ones would be defaulted to 0, and your paid ones will always have a value because it'll be required in the form.

Gonna have to see your stacktrace regarding that error. I think maybe you're just having trouble wrapping your head around everything. I had trouble with it for a while the first time I was trying to register and purchase at the same time.

As far as making sure your quantity is required:

validates :quantity, presence: true, numericality: { greater_than: 0 }

Yeah exactly, this would take care of it on a database level which would mean that your could should always have a value. And then not having a default on the booking is probably the thing that triggered the nil error. It doesn't super matter if you have a default value there, but it probably does make sense to add a validation requiring you to always have 1+ quantity on the booking so that value is never nil.

Posted in Problems Viewing Videos

Hey Thomas, did you get a chance to poke around any more on the videos?

Probably a good plan. Yeah the thing is that most times "multi-tenancy" is more for when you truly want separate databases and everyone's stuff separated out. I think it's a common misconception and one that's kinda hard to make clear at times. Sounds like a decent plan and you can always go back and change things up later, it just may take a little longer with production data later on which isn't that bad.

I would probably add a validation for the quantity on the Booking, and then you may want to add a before_save callback for Event to set to 0 if it is free.

before_save :set_zero_price_pennies, if: :is_free?

def set_zero_price_pennies
  self.price_pennies = 0
end

And you can also validate that Event always has a value for price_pennies of greater than or equal to 0 so that that column is also never nil.