Chris Oliver

Joined

293,020 Experience
93 Lessons Completed
295 Questions Solved

Activity

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. 👍

Anytime! 🍻

Hey Rob,

I can't remember exactly, but I know a couple people also had trouble with that one. I believe this was where we setup the form to submit as AJAX and hadn't transitioned it over to sending via the websocket just yet.

Your form is submitting, but it's not sending as a JS request, so your create action crashes looking for an HTML response. What you need is to add remote: true to the form so that will render and execute the create.js.erb file we created.

Basically just change this line: https://github.com/robSturcke/halibut/blob/4e4f4dce3360344f9326aee202d156591e2d67e3/app/views/chatrooms/show.html.erb#L12

to the following:

<%= form_for [@chatroom, Message.new], remote: true do |f| %>

That should do the trick! Your form needs to submit via AJAX request so that the browser doesn't reload the page each time you send a message. That'd be a really poor experience.

You're definitely far deeper into Searchkick than I've ever been at this point. :) I agree, some advanced searchkick usage like aggregates and geosearch would be really great to cover. Maybe some custom index stuff like what you're up to would be valuable as well.

So that import: false basically just tells it to create a blank index and ignore all the records in the database right?

Actually... you might check out what the Model.reindex code does. You might be able to pull some chunks from that to create your own method to do the bulk reindex and not clear the index each time. That might let you build a custom method for indexing that could take advantage of any bulk indexing they might have as well as support your multi-tenant application.

Posted in Group Chat with ActionCable: Part 1 Discussion

Credit for that goes to @andrew_fomera:disqus. :D

Posted in Create a welcome page with a tour/get started

This isn't quite the same, but something I thought I'd share: http://introjs.com/ It's used for a lot of intros that need to call out specific things.

The FitBit one looks just like a modal wizard, so you should be able to find some easy Javascript to pull that one off.

For the most part, you'll just want to keep track of whether the user is new by having a column on the user model that gets marked off like intro_complete once they're finished with the tour. You can display the tour the first time and when they close out of it make an AJAX request to mark that column as true so they don't see it again.

The kubernetes one probably just displays that whenever there are no apps, so it wouldn't have to keep track of whether or not the user had seen the intro.

I read this earlier and wasn't quite sure what it was, but that would explain it! :) Happy to help if you have any other questions.

Hey Drilon,

So sending emails is pretty easy, you can just configure ActionMailer with their credentials, but it's a lot more complex to receive emails in an application. There's a brief mention of that here: http://guides.rubyonrails.org/action_mailer_basics.html#receiving-emails

You can use the mail gem to retrieve emails from a pop server which might be what you want: https://github.com/mikel/mail#getting-emails-from-a-pop-server

Posted in Setup Windows 10 Discussion

It's likely that everything is installed but your terminal didn't automatically load rbenv again. Double check and make sure that you followed all the rbenv lines correctly to echo the lines into your .bashrc file.

For the select box, you can customize it to display user names using this: http://apidock.com/rails/v4...

Posted in Integrating Braintree (and PayPal) Discussion

You can definitely do that. What I would do is store the card on the user account after they pay the first time, and then the second time put in the existing card above the form and use JS to hide the Braintree form. This will let you use their existing card or toggle the Braintree form to use a different one.

You'll actually want to combine websockets with direct uploads (see: https://gorails.com/episode... ) in order to accomplish this. You don't want to upload files via websockets because they're not a good medium for this. Instead, you can upload files like you normally would and then you can use the response JSON from the upload to include the file in your application.

For example, Slack file uploads submit an AJAX file upload, you send over the message via ajax so you can upload the file and then once that's complete, it broadcasts it over websockets.

Awesome! :)

Posted in Direct File Uploads to S3: Part 3 Discussion

Great answer! :D

Posted in Direct File Uploads to S3: Part 3 Discussion

Should be very similar I would imagine although I haven't tried it.

Posted in Deploy Ubuntu 16.04 Xenial Xerus Discussion

You don't need to run Rails, Passenger will start the app for you automatically, that's why we set it up this way so you don't have to manage running scripts. It's automatic.