Chris Oliver

Joined

291,590 Experience
86 Lessons Completed
296 Questions Solved

Activity

Posted in Using Webhooks with Stripe Discussion

Have you printed out the result from this line? invoice.lines.data[0].plan

I'm wondering if it isn't returning a hash, but some other type (like maybe the plan is just the string ID instead and it doesn't auto-include the nested plan attributes). I don't know off the top of my head, but I'd recommend checking that out and seeing what you get.

Posted in Building a multi-location app in rails

This isn't entirely related, but did you know you can actually use multiple subdomains? It's rare and makes things more complicated, but you can do en.newyork.example.com if you wanted. I wouldn't recommend it, but fun fact. :)

I wouldn't recommend using multi-tenancy for this, but rather just scoping your results.

You'll want to setup the routes so that the first part of the URL is matched for the location, then you can lookup a Location record in your database, and scope all your controllers to @location. That way you'll get the effect of multi-tenancy but without the trouble by just making sure you reference @location.posts for example instead of Post.all.

Plus you won't have to worry about single sign-on because that only matters between separate domains generally.

Posted in JRuby on Rails and Java dependency management

I actually haven't used JRuby much at all personally, but I'm really curious about how this works as well. JRuby is a really fantastic project especially when you need to integrate with existing Java libraries.

Posted in integrating analytics

Analytics is a super good topic to cover. There's so much of it to take into account with all the tough questions of: Should I track this in the frontend or the backend? What should I call it? How should I save the metadata? How can we design this so it'll be valid data for a long time?

Also this is an awesome list of other production-ready topics. A lot of this is stuff I end up taking for granted, but absolutely needs to be in some screencasts.

Posted in Subscriptions with Stripe Discussion

Oh good question. Subtle thing here, but very important. The reason it's in the controller is because you're probably going to use the same logic to do authorization in the controller actions. You can easily expose the method as a helper using helper_method for the views, so this allows you to write it in one place and use it in both the controller and the views.

You'll have to make sure to modify your theme to use the image_tag or asset_url helpers in the views to point to the correct version of the image when it's compiled for production. There's also an asset-url helper for CSS that you'll want to use for any images referenced in the CSS.

Rails compiles these assets and the urls for them can change in production so you must use these helpers when you reference assets. That's the main modification needed to most themes.

You can do that, but you can also just use your normal text editor to create and edit the file. Macvim is just what I use.

Posted in Setup Ubuntu 14.04 Trusty Tahr Discussion

Thanks for much for that Zachary! :)

Posted in Multitenancy with the Apartment gem Discussion

Yep, I'm sure it can. You may have to build a custom handler for it based on their Subdomain one, but definitely could work. Check their docs / Github issues for more on it as I haven't done that before so I don't know the details of what you'll need.

Posted in Subscriptions with Stripe Discussion

Yeah, check your JS, verify the token gets submitted, something's definitely going on around that.

Posted in Subscriptions with Stripe Discussion

Are you sure that params[:stripeToken] is set to the value from the JS? Check your params?

Posted in Upgrade FedenaProject to latest Ruby application

I think the easiest way to do this is just to upgrade the Ruby version and see what happens. If they have tests, run the tests to see if they still pass. Other than that, you're probably good.

Posted in GoRails speed

Yes! I'm getting a new camera tomorrow, so this will be something I cover first with that. :D

Posted in Pair Programming on Rails Scopes Discussion

Definitely planning to! I think it helps explain things a lot better with the discussion.

Posted in Multitenancy with the Apartment gem Discussion

It works everywhere. You might need to make sure you have Puma running on the correct IP (I think in this case you'd want 0.0.0.0) and that you're accessing the host with the correct port as well.

Posted in has_one association on polymorphic model

You got it! :) So question for you: what are you trying to accomplish exactly with these queries? It might make sense to structure your data a little bit differently to make this more efficient. Your models sound like they're designed to separate everything, but your queries sound like you want don't actually want things separated.

For example, you're wanting to treat activities on notes and activities on comments the same, but your database is structured such that they're separate. It might make more sense to only have activities on the Note level and then include metadata for the related objects like Comment instead.

Posted in has_one association on polymorphic model

Multiple polymorphic associations can be tough because you can't do direct joins in SQL with polymorphic relationships since you're setting the table name in the column itself.

You'll have to make two separate queries along the lines of this:

@comment_ids = Comment.where(commentable_type: "Note", commentable_id: [1,2,3]).pluck(:id)
@activities = Activity.where(trackable_type: "Comment", trackable_id: @comment_ids)

That will first query for the comment IDs on those notes, then it will load up all the activities for those comments on the notes.

Posted in File Uploading with Carrierwave Discussion

That's what making 100+ screencasts will do to you. ;)

Posted in File Uploading with Carrierwave Discussion

I've been using Gravatars a lot lately so I haven't touched this in a while. Good refresher for me. :)

For avatars, I'm pretty sure resize_to_fill normally works best because it will resize the image to the proper dimensions and then crop from the center so that you get the best square images for it.

process :resize_to_fill => [400, 400]

This would always resize your image to fill a 400 by 400 space and then crop off the edges that are wider. In the case of landscape, it would adjust the height to 400 and then crop the sides out so the image is square. Portrait will do the same just cropping the top and bottom instead.