Chris Oliver

Joined

292,490 Experience
93 Lessons Completed
295 Questions Solved

Activity

Thanks for the tips! I'm not a Vagrant expert, so #2 was new to me. The chef recipe used to install bundler for me, but it doesn't seem to anymore either. Super annoying.

No worries! I'm going to re-watch it tonight because I'll probably have the same feeling and get you a much cleaner example including the controller that I eluded to but never showed. Showing the controller will clear up a lot of things I think.

I might re-record it with a clearer example. It could be explained a lot better.

Well, we actually eager load the sections, steps and privacy settings at the beginning through the course. That's all done and was the obvious thing to look at for performance, but the real bug here is more subtle in that we've loaded the object already but weren't referencing it correctly.

Those are all equally important in building performant responses though!

Pretty soon! It's a lot of content so I need to make sure I plenty of time to plan it all out.

Posted in Idea for TimeClock Need Advice

You gotta start somewhere. It's like art, just start painting. You can't plan a masterpiece, you've got to feel it out as you go (which is my main issue with TDD).

Last night I rewatched these two episodes and they gave me a lot of ideas on maintainable code:

https://www.youtube.com/watch?v=yhseQP52yIY
https://www.youtube.com/watch?v=mWo3oEwFFzM

Posted in Setup MacOS 10.10 Yosemite Discussion

Hey Sarah, if you haven't fixed this yet, the error basically says that your database password doesn't match what was set up with MySQL. If you used homebrew to install it, then the username is usually the same as the user you login as and the password is empty.

Posted in Idea for TimeClock Need Advice

Yeah refactorings are always really painful like that because you can't merge in the main application ever when it updates around this same code. This is where testing really shows its value, but versioning doesn't have a good way to handle this yet.

Posted in PDF Receipts Discussion

I will check it out! I did some research and can't remember why I picked prawn other than I saw enough other people using it and documentation seemed robust. That said, I bet wkhtmltopdf is way easier now that I've used Prawn more than a little.

The hardest part was building our completion certificates at OneMonth.com in Prawn. It was is finicky and time consuming.

Posted in Problem with upgrading to Rails 4.2.2

Haha! I was reading the title and was like hmm, I don't think I've upgraded to Rails 4.2.2 yet either. ;)

Posted in Idea for TimeClock Need Advice

If you're building this into an existing app, a branch makes sense. If you need to quickly prototype it without trying to fit it into the legacy code, it might make sense to try out a new app, but you'll still have to integrate it with the legacy code at some point. I'd probably go with the feature branch.

Posted in Recurring Events

Neat, I didn't know about Recurring Select. What kind of params does the recurring_select field send over? Their Readme doesn't really explain that.

Posted in Active Record Associations

You should be able to do this:

class Partner
  has_many :centers
  has_many :classes, through: :centers
end

Which Rails will know how to query based upon the other associations in the Center class. It basically compiles those associations together into the proper joins for you when you use the through option. You might have to tweak this a little bit for any class names or whatever that don't match up directly, but that should do the trick for you.

Posted in Idea for TimeClock Need Advice

Looks pretty good, but here's what I'd refactor:

class ClockEvent
  belongs_to :user

  scope :incomplete, -> { where(clock_out: nil) }
  scope :complete, -> { where.not(clock_out: nil) }
end
class User
  has_many :clock_events

  def clock_event
    @clock_event ||= clock_events.incomplete.last || clock_events.new
  end
end

Some changes:

  1. The scopes on the clock event make them useful for many other use cases, not just this one. Also I don't think you can use .last in the scope like you had, you'd want a has_one instead if you really wanted that or to use the last call attached to the scope like in my example's clock_event

  2. User now has clock_event which simply returns their current event. First it looks up any incomplete ones and grabs the latest one and if that returns nil it will create a new associated ClockEvent in memory. I cache that to a variable since you'll probably reference it a few times in your views and this will be important so you either don't query the record many times or create a bunch of new ones in memory each time you access the method.

  3. The completed? method isn't required for this anymore either because we're using the nil return value in the statement to trigger the || clock_events.new which is nice. Less code ftw, but you'll probably want completed? for rendering things in the view or logic elsewhere still.\

Hope that gives you some ideas! Looks great so far too.

Posted in Must Read / Must Watch

One of my favorite people on this planet, anything by Bret Victor is top notch. Here are three insanely good talks by him.

https://www.youtube.com/watch?v=PUv66718DII
https://www.youtube.com/watch?v=8pTEmbeENF4
https://www.youtube.com/watch?v=ZfytHvgHybA

Posted in Native Mobile Options

I think if you're shooting for something simple as a start, Phonegap and related options should work pretty well for you. I don't think they're awful experiences and they've gotten quite a bit better over the years. It's definitely worth a shot because your time investment will be so much smaller than trying to build a full API and native mobile apps.

From a quick google search, I found this and he builds a basic Phonegap app for a Rails app in under 15 minutes. Not too bad if you want to experiment with it and see what you get.

https://www.youtube.com/watch?v=LjIKElAP6_A

Posted in Refile :fill does not work for me

I'm not quite sure how the AWS storage works with the resized images. I'm guessing it downloads a copy of the image to your server from S3 and then resizes it, but maybe it's slow to reprocess things.

I wouldn't consider myself a refile expert and I'm not using it in production anywhere, but I would post this on the Refile github issues: https://github.com/elabs/refile

Posted in PDF Receipts Discussion

I haven't yet, but really want to. Obviously the HTML to PDF will be way easier than how Prawn does it. The programmatic generation is no fun at all.

Posted in Setup MacOS 10.9 Mavericks Discussion

This is basically saying that you're not using the rbenv version of Ruby and you're using system Ruby which you don't want to do.

Try restarting your terminal and double check your ran all the commands. The output you should get from the "which ruby" is something like this "/Users/chris/.rbenv/shims/ruby" when it is set up correctly.

Posted in Idea for TimeClock Need Advice

I think current_clock_event probably makes sense in the controller because you might need it for rendering in the views to remind the user it's not finished. Like you said, you'll need to be able to reference it from the model for proper scoping, so you may technically need it in both places if you add it to the model first and then make a controller method to make it easier to access.

It make sense to cache the value of total_hours on the model after save so that you've always got a queryable value. Would definitely recommend that.