Chris Oliver

Joined

291,540 Experience
86 Lessons Completed
296 Questions Solved

Activity

Yeah, thanks! I know that the react_on_rails gem actually uses webpack for compilation but uses the asset pipeline for the embedding into Rails which is nice. I'll have to dive into these articles soon and start planning a webpack episode.

Posted in Direct Messages in Realtime with ActionCable Discussion

Just like we did in this episode, you create direct messages between two users by using them in the pubsub channel name. Nothing different there.

For the popup UI, add data attributes to the link so when it's clicked you can find the User ID of the person you want to direct message. Then you have both the current user, and the recipient ID which you can use to start the pubsub channel between the two people.

Posted in Direct Messages in Realtime with ActionCable Discussion

Absolutely. You can create any UI you want for this. My example is more like Slack, but you can do the same thing and use the button to initialize displaying a popup chat box instead.

Posted in Inviting Users with devise_invitable Discussion

Thanks for sharing Anthony! I'm sure people will find that useful. :)

Yeah, I'm gonna talk about Webpack in the future when we get into the frontend framework stuff. It's one of those things that I'm disappointed Rails hasn't improved the asset pipeline enough speed wise, because it doesn't feel like the most useful use of your time to be fiddling with WebPack configurations.

I still very much appreciate the convention over configuration approach Rails takes, just need to get some speed boosts in there and things would be great.

Posted in Searchkick search_data not working

Hey Alex,

That error is pointing out that it called .name on a class that was nil. The only line in your code that does this is category.name which means that you have a Recipient record without a category on it.

You probably want to conditionally pass in the category name if you want category to be optional.

            # using a ternary if statement
      category_name: category.present? ? category.name : nil

            # or, often not recommended to use try(), but a bit cleaner way of doing the above.
      #category_name: category.try(:name)

Posted in Shrine Backgrounding and Video Transcoding Discussion

Oh nope, screenshot should be .jpg if it wasn't.

Posted in Comments With Polymorphic Associations Discussion

Ah, I gotcha. So in your films/comments_controller.rb you could say:

def index
@comments = @film.comments.where(status: 'published')
end

And then you would want to build the index.html.erb to display all those comments. Is that what you're looking for?

Posted in Comments With Polymorphic Associations Discussion

Hey Melanie! :)

If you wanted a route to get all published comments (not ones scoped to a commentable type) you could add a resources :comments that was not nested in your routes and use that.

  resources :comments

resources :actors do
resources :comments, module: :actors
end
resources :films do
resource :comments, module: :films
end

And then you could make a comments_controller.rb that worked for all comments for any object. Is that what you're looking for?

Posted in Use .ENV instead of Secrets.yml for keys

Yeah, Heroku's stuff is easy because you can say heroku config:set AWS_SECRET_KEY=xxxxxxxxxxxxx and it will set the ENV variable for you, and voila! You've got ENV variables set.

Much easier than doing that on your own server since nginx doesn't let you set ENV variables in your server config. When you've got your own server, it's easier to write the secrets.yml file on the server only in the shared directory between deploys and then symlink it during deploy instead rather than using ENV variables.

Posted in simple mde duplicates

You've added "ready" to the event listeners which I did not have. Remove those so that it matches mine and your code will work.

You don't want to use the "ready" event for Turbolinks because that will cause your code to run twice on the first page load. Just use the Turbolinks events like I showed and you'll be fine.

Posted in Group Chat with ActionCable: Part 6 Discussion

Yeah, you'll want to sanitize it. I can't cover everything in the series, so that's one you'll have to add in. Good catch, it'll be useful for anyone else following this to be aware of that.

More stuff coming soon! :D

The simple solution for most of Bootstrap is just to use the turbolinks:load event for re-initializing your JS. For example, to enable tooltips and popovers for all pages, you can do:

$(document).on 'turbolinks:load', ->
$('[data-toggle="tooltip"]').tooltip()
$('[data-toggle="popover"]').popover()

Some of the other things like bootstrap modals don't need this because the JS is written in a way that makes it automatically compatible from what I've seen. Bootstrap 3 doesn't have too many compatibility issues with Turbolinks 5 these days.

Posted in rails5 + heroku + cloudfront + fonts

Yo Szilard! It's been a while since I've setup Cloudfront especially with fonts.

Did you make any progress on this?

It's not quite right. You do lose some of the benefits of sass if you use requires because you can't share sass variables or mixins between files with requires like I talked about in the episode.

The thing they don't talk about is the compile times are incredibly slow when you don't split up your code in requires. When your sass code is modular, you can absolutely split it up and use requires for compile performance in development.

Hey Emil,

For the most part, you can just plug in Shrine by opening up a File object in Ruby and then assigning it to the shrine attribute and calling save. That's basically the same process that Shrine uses on a browser upload so there is little to no difference to do this from an already downloaded file.

download = File.open("PATHTOFILE", "rb")
@record = Record.where(youtube_id: ID).first_or_create
@record.video = download
@record.save

You might need to delete the file you downloaded once this is complete so you don't have duplicate files on disk.

These are likely the two main ones that could be misconfigured:

1. Make sure elasticsearch is bound to the public IP address and not just running internally.
2. Check to make sure the port is open on it through the firewall.

It's probably one of these two but could be something else. It's been a while since I setup ES across machines.

Posted in How to send Webhook?

That's relatively easy. You can just save a record for every attempt and create/update those according to the number of attempts and they display them on that page. Just need to record the results of the background job after it succeeds or fails and that should be it!

Posted in Direct File Uploads to S3: Part 1 Discussion

So Heroku won't actually allow you to store files permanently on their servers. You are required to use an external storage service like S3.

If you deployed to Digital Ocean, you can store files since you control the server. Migration isn't the worst, but it can take some time. If you plan on people uploading a lot of files, it's probably worth just using S3 from the beginning.

In either case, I guess I would say you might as well just use S3 from storage from the beginning if you plan to using S3 later.