Chris Oliver

Joined

293,020 Experience
93 Lessons Completed
295 Questions Solved

Activity

Posted in Setup Ubuntu 15.04 Vivid Vervet Discussion

The difference is just that the PPA gets updated more often (if the maintainer keeps up to date) vs the Ubuntu repo which only gets updated once every major version change. You'll get a stable version of Nodejs, but it will only receive small updates and security fixes, not major version changes.

Posted in Multitenancy with the Apartment gem

  1. I think the key piece there is modifying the find_for_authentication method. You'll have to join the user and company tables to get only the users for that company. Adjusting that query so that you work through the associated company will do the trick.

  2. What's up with background jobs? If you do need background jobs, there's a apartment-sidekiq gem that can help by switching background jobs into the correct tenant.

Posted in Multitenancy with Apartment Gem

Actually I just found this: https://github.com/influitive/apartment/pull/208

Looks like you might need to set the environment variables he mentioned in order to get pg_dump to run correctly. Wish I had found this earlier for you!

Posted in Deploy Ubuntu 14.04 Trusty Tahr Discussion

Read the Rails and Nginx logs to check for errors. I didn't cover the part of setting up the database.yml and secrets.yml files.

Posted in How can I grow this search object?

There's actually a lot going on here and I can see several bugs because there is logic smattered all over. My impression is that you've extracted lines of code into their own methods too early before you knew exactly what you were trying to accomplish. That left you with a bunch of methods and several of them having their own little bits of logic. There's no clear path that anything flows which makes it hard to understand at a glance.

I think you have felt this and recognized it, so the question is how do I get back to sanity? And the answer is by making your code uglier. Remove all these method calls and put the code back inline. You only call most of these methods from a single place so removing the methods and putting them back inline clarifies things a lot. You can then see what's duplicated. Make the search method contain all the logic and then refactor it.

From what I can tell you always want to exclude the image ids, yet you do this in many different places so it's hard to realize that. Your search method could actually start by calling Image.excluding first and then tack on the other scopes instead. I'd do a refactoring myself and maybe a video of it if I had the time, but hopefully that makes sense as an approach to start refactoring.

Posted in Multitenancy with Apartment Gem

It sounds like you may not be passing in the right database username. You should put in the username that you use to login to the database. It will be the same username in your config/database.yml file. For example, mine is -U chris in the command.

Awesome! :) Let me know if there's anything I could cover that would be helpful too.

Posted in Introduction to Importing from CSV Discussion

I believe I covered a bit more of this in a following episode, but you're absolutely right. This is where a form object of some sort makes a lot of sense. You can have it wrapping these things and then translate it to errors in the UI. This being a rake task makes that hard, but a controller variable for a form object would help that.

Posted in Setup MacOS 10.10 Yosemite Discussion

Haha! Thanks :)

Posted in How can I grow this search object?

What are the collection_id and selected images parts? I could use a little more context to determine what I'd suggest but I don't think you're far from a good solution.

[Edited]

So all the Time instances in Rails include a date with the Time. It will default to January 1st, 2000 as you can see but you can safely ignore that portion of the output.

You should be able to query the database just by doing this and it should ignore the Date portion of the time. Check the development logs for the SQL query to make sure it does.

 Fpclass.where('start_time>?', Time.zone.now)

Posted in File Uploads with Refile Discussion

Check out this section in the Readme which should get you sorted out. https://github.com/refile/r...

Posted in Manage Assets With Rails Assets Discussion

If you're trying to customize something like bootstrap, you can do this: Instead of doing the *= require bootstrap, you can do @import "bootstrap" to import the file using SASS and put your custom variables above the import to override the defaults.

Basically it doesn't change from how you would normally do it, but it can be a little unclear since they don't give you any instructions. Does that make sense though?

Posted in Manage Assets With Rails Assets Discussion

You are correct. It'll use that latest version of the library. And thanks! :D

Posted in Manage Assets With Rails Assets Discussion

I believe it works by just setting the version on the gem you include.

gem "rails-assets-bootstrap", "1.0.0"

Posted in Manage Assets With Rails Assets Discussion

Awesome post! Thanks for sharing that Mohnish.

Posted in Page Specific Javascript

That's actually what I would recommend doing. If you set up your JS to look for data-behavior tags like I covered in this episode you can load things into those tags.

The best way is not to really have page specific javascript, but instead to have these little widgets that can be reused anywhere by detecting things on the page. It'll keep the JS and Rails code very separate and the flexibility of making it not tied to specific pages helps a lot in the future.

Posted in Manage Assets With Rails Assets Discussion

If you haven't tried this already, you'll probably want to include bourbon with @import instead of the require statements so you can use it in your sass code.

Posted in Manage Assets With Rails Assets Discussion

It should, but with more complex things like ckeditor, you might have to have those lang/en.js files compiled separately. Something like this based upon the filename in the Rails Assets gem.

config.assets.precompile += %w( lang/en.js )

This is definitely one part where the documentation with Rails Assets is poor.

Posted in Introduction to Importing from CSV Discussion

Definitely. This is where form objects tend to make a lot more sense because it's that much more complicated. An intermediate step of uploading, processing, and finding errors before doing the actual import can be a good thing for this too.