Chris Oliver

Joined

290,710 Experience
86 Lessons Completed
298 Questions Solved

Activity

I think its mostly just not taken off due to habit. We've had position arguments and then optional hashes which are pretty much keyword arguments so it's not a big change, but it's definitely a nice one.

It's probably a good habit to start using them where they make sense from now on. I'll probably just keep forgetting to do it though. :)

Hey Earl,

What I would do is create an activity model, so you would keep track of the views, discussions, etc in a table, and then you can query for those within the last 24 hours and then count them up to determine which were the most active topics. You can query for the different types of activities and weigh some of those more than others (like comments might be more valuable than likes or something).

Does that make sense?

Here's a good article on how you could move that stuff into Postgres as a function: http://sorentwo.com/2013/12/30/let-postgres-do-the-work.html

I should definitely do a screencast on this stuff.

Posted in Searchkick search_data not working

Hey Andrew, did you get this one figured out?

I know the feeling all too well. :)

Oh I gotcha, that should be much simpler.

I believe you'll need to override the Devise Registrations controller and just define the layouts in those methods.

# config/routes.rb
devise :users, controllers: { registrations: "users/registrations" }
# app/controllers/users/registrations_controller.rb
class Users::RegistrationController < Devise::RegistrationsController
    layout "new_registration", only: [:new, :create]
    layout "edit_registration", only: [:edit, :update]
end

Something like that should do the trick.

I would actually recommend not trying to modify this because that's how Rails generally works. The thing is that your form submits a PUT request to /users when you edit your user, so when it fails, the request returns HTML and that's why your browser ends up on /users instead of /users/edit. Since it doesn't do a redirect in order to preserve all the variables, it has to keep the URL on /users in order to generate the next page that includes the errors on it.

For you to modify that, you'd be going against the way the routes work in Rails and so your solution would be kind of hacky. This does tend to feel a little weird in development when you're testing things, but when the app is live, you'll never notice it because you won't be typing in URLs direct hardly ever.

Does that make sense?

Posted in Verifying iOS in-app purchase receipts

Hey Michael,

I'm really curious about this as well. Do you know how the process of these purchase receipts work? How do you receive the receipt data? Do you get it in-app and then have to send it over to your server for verification?

Hey Jeramae,

Are you using jQuery autocomplete for the frontend? I wonder if that's having trouble on Safari or something. It isn't likely to be the server-side ElasticSearch or Searchkick stuff if it's working fine in other browsers.

Posted in What is the best way to handle omniauth

That's one of the tricky situations you have to handle with Twitter. I need to do a screencast on this, but the idea is pretty simple and here's a link to check out in the meantime: http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/

Basically you setup the OAuth process as normal, but if the user goes through it and doesn't return an email address, you have the add in an additional step to gather their email address and/or password.

Posted in Devise: Add a select to my signup form

I would just open up an issue on their Github, ask if they'd be interested in the idea and if so, what are the things they'd like to see for it? code and document obviously, but does it need tests? that sorta thing. They're super helpful and that's basically what I did when submitting a suggestion for a feature on Devise previously.

Posted in Devise: Add a select to my signup form

You know, it'd be kind of cool if someone added a generator to Devise that would allow you to add this code into ApplicationController automatically so you didn't have to look it up each time. Maybe someone should make a PR on Devise for this idea... hint hint 😉

Posted in Migrate away from Mandrill?

Hey Mel! For the most part, they're going to be the same. You'll just setup your Rails server to connect to their SMTP server. Sendgrid has instructions on this here: https://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html

It's the same way you would connect to Mandrill, Mailjet, Sparkpost, etc over SMTP, just using different credentials and a different server address. I'll try to do a screencast on this sometime soon!

Posted in How do i create another table when a user signs up?

Hey Alan, check out this episode: https://gorails.com/episodes/forum-nested-attributes-and-fields-for

Basically what you can do is setup a form that assigns attributes to two models at the same time. This will let you create a user and their associated Company record in a single form. 👍

Absolutely! Any other specific topics you'd like me to cover?

Hey Earl!

You can put the sign in and sign up forms anywhere you want (including on every page if you wanted it as a modal or something). Check these links out:

https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app
http://stackoverflow.com/a/17001874/277994

Posted in Group Chat with ActionCable: Part 2 Discussion

Basecamp uses Turbolinks and the ActionCable JS on mobile to power their app, however I'm sure you could port the client over to a native Swift or Obj-C client that would allow you to build a native app. It'll probably be a decent amount of work to start, but this is an example of someone who build an ActionCable client in Ruby (rather than the default JS) so you could probably use it as a basis for building a Swift client.

If you just go with Turbolinks views on mobile, you'll have a really easy time making this all work because the mobile UI will be the exact same code you use on the desktop browser.

Posted in Group Chat with ActionCable: Part 1 Discussion

Those are actually just the LastPass extension trying to save my passwords.

Posted in Old Rails 2 Delayed_Job User_Mailer Question

It's been a really long time since I've used Delayed Job, but here's what I'd do:

  1. Try checking for DelayedJob errors. I'm not sure how you do this, but they are either logged in the database or in your Rails log file I'd guess. I'm sure you can find information on this on their Readme/Wiki or on Google.
  2. If you don't find anything, you can try running the same code that your background job does, but manually in the Rails console in production. You'll then know if your code was wrong if that succeeds or not. Chances are there's some sort of SMTP authentication issue or something.

Posted in Group Chat with ActionCable: Part 1 Discussion

I'm using Monokai in just about all places, vim, zsh, etc.

Posted in Group Chat with ActionCable: Part 1 Discussion

Just published it! https://gorails.com/episode...

I'll be publishing about one a week so I have time to get through everything.