Chris Oliver

Joined

292,890 Experience
93 Lessons Completed
295 Questions Solved

Activity

Posted in Saved messages as HTML

Hey Martin!

This is actually a small bug you find in the JS for that episode. The append() in handleChange works fine for adding plain strings, but not HTML ones to the value of the inputs. If you change the append line to the following, you'll see that it works just fine:

    comment_body.val comment_body.val() + saved_message_text

This is a better way of adding text to a field, where you set the value to the old value plus your new text. Append seems to do that, but not when there is html that you want to add for some reason.

I updated the repository to fix that bug as well. 👍

Posted in Group Chat with ActionCable: Part 1 Discussion

Hey! I believe that should be just

><% current_user.chatrooms.each do |chatroom| %>

because we didn't build anything called "public_channels" I don't believe.

You can find that line in the github repo here: https://github.com/gorails-...

I believe I introduced a bug related to this at one point which you might be running into. Check out the code on Github in the notes on the episode and you might spot the fix I introduced. Can't remember exactly what it was.

Ah, so the error is saying your @chatroom_user record is nil (didn't get saved for some reason) and therefore your last_read_at didn't work. Slight different than the error I was originally thinking of. Check your @chatroom_user gets set properly in the controller and why that might not be set.

Yep, that looks right. Your Rails app doesn't seem to know that exists though which means there's some discrepancy. Maybe try restarting your Rails server in case it didn't pickup the migration or there might be a typo somewhere I'm not noticing.

Or maybe you've got a different error than the one I'm assuming you've got. Can you paste the full error?

If it's a no method error, make sure you ran the migration to add that column to the ChatroomUser model. The no method error usually comes up when a column doesn't exist that you try to access.

Actually ice_cube has yaml, hash, and ical exports so that probably makes it a better solution at the moment over Montrose for this purpose. I'll probably try to cover both and not the differences between them.

Ah yes, that's one of those special cases that can be hard to solve. I'll try to cover that use case in the episode or a follow up if I can. I think what you'd want to do in that case is to save that date like a non-recurring event and then add an exception to the recurring events for to skip that date. Kind of confusing, but should do the trick assuming they can handle that.

Looking forward to covering this finally. I should have done this months ago. ;)

I'm going to put it on my recording schedule to record this week.

Yes! This has been on my todo list for far too long. I will most likely be using the https://github.com/rossta/montrose gem for this because it helps generate those future dates and things really nicely. This doesn't really have anything related to saving these objects to the database, so I think that would be hugely valuable along with some simple_calendar support. :D

Just update the Mailboxer config to disable sending emails and you should be all set:

  config.uses_emails = false

Interesting. I've seen some odd things with caching in the browser sometimes and that could definitely do it. Plus they update Chrome so often these days that you never know when they might introduce a small bug or something.

Very glad you're enjoying the series. I had a lot of fun making it! 😎

Posted in Group Chat with ActionCable: Part 4 Discussion

Ah ha! That would do it! Good find. 👍

Haven't seen this myself. What logs are in your Javascript console?

Posted in Group Chat with ActionCable: Part 4 Discussion

Hard to say off the top of my head. You might just need to put in some more debugging lines to make sure that everything is connecting correctly. Make sure that 1) the JS connects to the websocket by watching the Chrome network logs 2) Make sure that your server side background job is executing by printing out in your logs 3) Make sure your user is connected to the channel so their websocket streams from it correctly.

Probably something small isn't connected right and it should be an easy fix once you figure out what it is. Also here's the link to the final app code for this that might be of help: https://github.com/gorails-...

Posted in Direct File Uploads to S3: Part 1 Discussion

I would still recommend setting your domain explicitly. You can use in it to specify a wildcard subdomain so you can handle all of those.

From their docs:

In the AllowedOrigin element you specify the origins that you want to allow cross-domain requests from, for example, http://www.example.com. The origin string can contain at most one * wildcard character, such as http://.example.com. You can optionally specify * as the origin to enable all the origins to send cross-origin requests. You can also specify https to enable only secure origins.

Posted in Direct File Uploads to S3: Part 1 Discussion

AWS docs are some of the worst. Plus every little thing has it's own acronym which makes it even tougher to sift through!

Posted in How return has_many with array instead of object

We chatted in Slack about this and our solution was to use a custom method here in the serializer to build the output as an array of strings rather than an array of objects.

class UserSerializer < ActiveModel::Serializer
  attributes :role_names

  def role_names
    object.roles.map(&:name)
  end
end

Yeah, it's now the default for Rails I believe, so it's a required dependency if you use the defaults. Super easy install with homebrew and everything should be automatically working for you after that.

Your redis server isn't running. If you installed it with homebrew, you can type brew info redis to see the instructions on starting it up again.

Yep, that'll work fine. You don't have to worry about the redis url at all for that. This is a validation to make sure that the browser origin (the domain that attempted to connect to the websocket) is an allowed one.

Basically you don't want someone on another website stealing your chat messages from another site, so this is a protection built-in for that.

It should default to allow localhost:3000, but it seems people are having trouble with that. Your solution is correct, and you'll add to that when you deploy it to production. 👍