David Moore

Joined

30 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Rails Counter Caches Discussion

That makes sense. Just an interesting observation. Great post btw.

Posted in Rails Counter Caches Discussion

I noticed that the user model had to be reloaded to decrement but not to increment in a spec and the rails console in a version as late as 4.2.7.1
.

describe "counter caches" do
it "increments associations when created" do
user = User.create(first_name: "David", last_name: "Moore", email:"david@moore.com")
user.forum_threads.create(name:"First thread")

expect(user.forum_threads_count).to eq 1 #passes

ForumThread.create(name: "Second thread", user: user)

expect(user.forum_threads_count).to eq 2 #passes

#destroy a forum thread and check if form_threads_count is updated
ForumThread.last.destroy

expect(user.forum_threads_count).to eq 1 # fails
expect(user.reload.forum_threads_count).to eq 1 # passes
end

Posted in Setup MacOS 10.9 Mavericks Discussion

Or just use thoughtbot's laptop repot.

https://github.com/thoughtb... (for mac users)

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.