27 Nov '13, 5pm

merging scopes with STI models - Pivotal Labs:

On a client project recently, we ran into a domain problem that didn’t fit into the ActiveRecord standard conventions. The following is the thought process taken to get to our solution, so it gets detailed in some areas. ActiveRecord has a great feature called Single Table Inheritance . It allows a model to have multiple types while using a single database table for the storage. Those type abstractions can each have their own validations, override base functionality, and specific abstraction functionality. If your model has ever been littered with case statements checking if a User is a guest, admin, etc., you should take a look at STI. Models The project had a based model that had many types and each abstraction had a scope of .active that defined what it meant to be active for that type. class Person < ActiveRecord::Base; end class FireFighter < Person def self.active wh...

Full article: http://pivotallabs.com/merging-scopes-with-sti-models/

Tweets

@pivotallabs We transform how the world builds ...

pivotallabs.com 28 Nov '13, 2am

Why pair design? This post has been pair-authored by Kim Dowd and Pam Dineva, designers at Pivotal Labs. Consultancies and...

Go Ask The User!

pivotallabs.com 26 Nov '13, 4pm

Lean Startup methodology and Agile development preach customer driven development and all it’s benefits. I think real worl...

“CSS :first-child, :nth-child, and :last-child ...

pivotallabs.com 28 Nov '13, 5am

One mistake I’ve seen made a few times is the notion that CSS’s nth-child pseudoselector acts like jQuery’s :eq pseudosele...

DREAMer Hackathon for Immigration Reform @FWD_us via @ninamehta - Insights & Review

DREAMer Hackathon for Immigration Reform @FWD_u...

pivotallabs.com 26 Nov '13, 9pm

Thirty-something years ago, my father moved to the United States to be the first in his family to earn a graduate degree. ...

Insane Makeup Turns Models Into 2D Paintings

fubiz.net 26 Nov '13, 4pm

, le photographe russe Alexander Khokhlov est de retour avec un nouveau concept unique et beaucoup plus de couleurs. Une c...

What Powers Pivotal Tracker: Client side archit...

pivotallabs.com 19 Nov '13, 11pm

So what makes Tracker work? I will be doing a series of technical blog posts to explain that, starting with a deep dive in...

Ascaso Grinder - i1, i2 Models, Julien Labelle:...

coffeegeek.com 28 Nov '13, 2am

I have bought this grinder after a lot of research and reading a tons of review, trust me. My budget was 300$ and i haved ...