Chris Oliver

Joined

290,800 Experience
86 Lessons Completed
298 Questions Solved

Activity

Posted in Multi-event .ICS file generation?

I haven't, but it definitely looks like ri_cal hasn't been touched in several years. I'd probably have to recommend iCalendar just based on that but their documentation and API don't appear to be the cleanest.

Wish I had more information for you on it, but I haven't had to create .ics files before. Maybe that'll make for a good screencast.

Posted in Liking Posts Discussion

The easiest way is to use a counter cache column. It can keep track of how many likes each post has and saves it on the post so that you can quickly and easily query that. There's an old Railscast on it that I'd recommend: http://railscasts.com/episo...

You could also do it with a join and a group by query, but a counter cache will let you sort the information at any time quickly.

Posted in Multi Model Sign-up Wizard

Are you trying to create a company before they create a user on sign up?

What I do in this case is use the user registration form and do fields_for :company inside of it. That way you can't create a company without attaching it to a User. I can ask for teh company information first, but in the same form I also submit the user details which save the company and associate the user as the "Owner" of the company.

Am I following you correctly?

Looks like you can if you add the "dateext" option. More details here: http://www.thegeekstuff.com...

Posted in Pagination with will_paginate Discussion

Great idea! I've done that in the past when I wasn't sure why it wasn't rendering and that helped a lot. :)

Posted in Refactoring Controller Methods Discussion

That's definitely an option. I prefer not to because the QUESTIONS are related to business logic regarding some type of model and the SMS class just purely contains logic on how to send an SMS. This way it's separated from other concerns and is purely on its own. You could extract this out into a library if you wanted to share it between apps for example and you wouldn't have the QUESTIONS and other dependencies.

Posted in Refactoring Controller Methods Discussion

Oh yep, you're right. It's easy to miss stuff like that when you can't actually execute the code.

Posted in Refactoring Controller Methods Discussion

Whoops, you're totally right! Thanks for the comment. That was my bad. I knew I was probably overlooking something calling it "send".

Definitely a problem when you don't have the full Rails app to test your refactorings against.

Posted in Refactoring Controller Methods Discussion

I'll be sure to cover more topics then! Feel free to email me any examples of code you'd like to see refactored and I'll see what I can do.

Posted in Authorization With CanCanCan Discussion

Check out rolify for database backed permissions. It is pretty flexible and shouldn't cause much if any downtime if you migrate from static permissions to database ones. You'd simply create the role records in the db before deploying the rolify backed cancan config so that there was no trouble.

Definitely wise to have expirations on tokens. Also you will probably want to tell your users to keep the token secret (like don't commit it into a git repo for example). There's not much way around that because any API token is going to let you access the site on behalf of a user since that's what they are designed for. Just want to make sure to educate users to protect their tokens just like they would their password.

Posted in Nginx.conf failed

That would do it! Sometimes the file permissions or ownership will do that. I've often accidentally run a command as sudo without realizing it would change ownership of my app files and all of a sudden Nginx can't read the Rails app anymore.

Thanks for sharing your solution! :)

That's the plan. Twitter is a bit frustrating because it doesn't give you an email so you can't create Devise users easily with it. Need to store the OAuth hash in the session so you can ask for an email first. I'll be doing an episode on that soon.

Posted in Liking Posts Discussion

Yep! You can make the likes polymorphic if you want them to apply to more than one model. That would let you add likes to Threads and Posts. You'd build it pretty much the same way and that should do the trick.

Posted in Nginx.conf failed

Hmm, sounds like something wrong there with the config. You definitely just want one line that says passenger_ruby and it should point to the wrapper version of it, not the same as which ruby outputs.

As far as what to check next, look at /var/log/nginx/error.log and see if there is anything in that file (or other files in the same folder) to see what it says when you get the 403. That will probably give you the best idea of what's wrong.

Posted in Multi Model Sign-up Wizard

  1. It is usually wise to always require an email and optionally do the username. One reason is: how does a user recover their password if you don't have their email?

On a side note, you can easily add usernames to Devise and they definitely can be easier to remember. Check this out if you're interested in sign-in with both. https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address

  1. You know how some sites (like Slack.com) use a subdomain for the company? That's basically for exactly that problem and each company gets to choose their subdomain or "username" if you will. You could have two "ABC Widgets" companies but they would have different subdomains.

  2. You can use nested model validation to take care of that. If any of the records isn't valid, it will roll them back. You'll want to do nested form for those things. Like a form_for @user with fields_for :company and fields_for :role so that it's all contained properly. More info on that here: http://homeonrails.com/2012/10/validating-nested-associations-in-rails/

Posted in Using Pundit with ActiveAdmin

I haven't used Pundit with AA, but I was going to mention the adapter. Not quite sure what to suggest from here. Maybe there is a typo in there somewhere causing it to be unable to find it?

Posted in File Uploads with Refile Discussion

You can upload anything with it. You'll want to check out https://zencoder.com/en/ for transcoding. If you set Refile to upload to S3, zencoder can take it from there. https://github.com/zencoder...

Posted in Setup Ubuntu 14.10 Utopic Unicorn Discussion

Awesome, thanks for the heads up Isaac!

Posted in Deploy Ubuntu 14.04 Trusty Tahr Discussion

You can do "rbenv rehash" to make the cap executable available like a regular command.