Chris Oliver

Joined

292,390 Experience
93 Lessons Completed
295 Questions Solved

Activity

Posted in Good public national holidays api?

That gem looks great. Might be your simplest solution as well. Google Calendar API sounds like it's not always the most accurate according to StackOverflow. I imagine that Wikipedia's list of holidays for countries is pretty accurate, but you'd have to scrape them periodically in order to get any changes.

The stuff I've done in the past was just simple and was for the US only so I haven't had any experience with the smaller EU countries which will be the ones that will give you the most trouble I'm sure. I'd try this gem and worst case you may have to add some data to the yaml files in there.

I can imagine since this is pretty hard to do, that's why the one API can cost $100/yr. That's really not too bad considering all the work they probably have to do to continuously update it. Too bad there isn't a simpler, free option that's always up-to-date!

Thanks for the kind words! :) I'm glad you're enjoying it.

Posted in Good public national holidays api?

I haven't actually used any APIs for this in the past, but found a good list of them here: http://stackoverflow.com/questions/14203708/is-there-a-comprehensive-api-or-json-xml-list-with-public-bank-holidays-worldwid

It looks like the most reliable one will be the timeanddate.com one, but it's $100/yr to use. I'm sure it costs money because they actually support it well compared to the others.

http://holidayapi.com/ is another that might be alright, but someone said it didn't work correctly when they tried it a while back. Maybe it's working better now though!

Posted in Authorization with Pundit Discussion

Whoo! That's one of those gotchas that I didn't even think of until you mentioned it. :) Glad you got it working!

Posted in Authorization with Pundit Discussion

Is "category" an instance or the class of the model itself? Only the instances have the relation so maybe you're testing the model? You may want to inspect exactly what the variable "category" is in the console.

Posted in Setup Ubuntu 14.10 Utopic Unicorn Discussion

That seems awfully long. Usually it's about 15 minutes or so. Sometimes it can stall because of low ram. You might restart it and see if it finishes sooner. I'd also recommend trying the $10/mo server because it has a bit more power for compiling.

Posted in Authorization with Pundit Discussion

The error is happening inside Pundit. Check line 11 in your category_policy.rb. You're calling ".user" on something there that isn't valid. :)

Posted in File Uploading with Carrierwave Discussion

You're probably doing a loop in the index page to list all the users, so you'd say "user.avatar_url(:thumb)" instead of "@user". :)

Posted in Multitenancy with the Apartment gem Discussion

Yes indeed! :) Mistakes in video are forever... ;)

That will work! :)

The answer is simple enough that you might kick yourself. :)

You can simply call the policy inside the other one. Here's an example I found on Stack Overflow:

def edit?
  # I am assuming that a user can edit themselves, so the "or" is in there, if not, go back to using and
  document.user_id == user.id or UserPolicy.new(user, User.find(document.user_id)).edit?
end

http://stackoverflow.com/questions/26514769/nested-pundit-policies

Ah yeah! I've had to remove bin from that as well. Not sure what changed but that definitely fixes the problem.

Posted in how scrabe data every day

You guys are awesome. :)

Mechanize is good. I've used that before. I've never checked out Scrapy or Wombat, but I'm sure they are awesome too.

Using whenever to schedule this script every morning will make that part easy.

I'll see about adding this to the list of screencasts to cover!

If you're using Devise, as long as you do the email/password registration as the first step, that makes it pretty easy. You can use like https://github.com/schneems/wicked to setup the rest of the steps.

I would just put a before_action around all your controllers so that it forces your user to an "awaiting approval" page until they are approved. You can still let them log in and view their account but they won't be able to do anything.

Posted in Using Vagrant for Rails Development Discussion

Sounds like you installed the vagrant rubygem before. You'll want to uninstall that and download it from vagrant's website instead.

Posted in Comments With Polymorphic Associations Discussion

You shouldn't have any trouble. Rails handles it well. But you're right that with polymorphism you don't get the same database level enforcement like you would with the individual associations.

I haven't personally run this in production yet, but you might check out this screencast. https://www.driftingruby.co...

Posted in Comments With Polymorphic Associations Discussion

If you don't go with polymorphism and you want comments on multiple models, you will need to have two different tables for comments, like PostComments and UserComments, but why do that when you could combine them into just Comments? Really that's the main difference. You reduce duplication there.

Hey Stefan,

So my advice with storing this stuff in the model is only to do it if you'll need it for queries. I think that'll be important (filtering by businesses that are open) so it makes sense to be there. Do you have a data format for saving the hours the places are open? Will they always be a consistently open chunk of time like 9-5? I imagine days and weekends will have different hours too. Do you need to handle that as well?

I hope you can get a Jr Rails position soon! I should do a screencast on talking about how I got my first jobs as a developer.

HJKL in vim for movement scared me off but I actually just used the arrow keys for most of the first few months. That saves you a lot of trouble (and so does the Janus set of plugins).

I'm glad you've been enjoying everything!!

Posted in Comments With Polymorphic Associations Discussion

The main difference is that you probably have tied your comments to the Post model. With polymorphism, you could have comments on the Post model, the User model, or any other model you've got.

And thank you a bunch for subscribing!!