RailsCasts Pro episodes are now free!

Learn more or hide this

Sid Krishnan's Profile

GitHub User: sidk

Site: http://ducktypelabs.com

Comments by Sid Krishnan


For anyone interested in diving deeper into scopes on associations in Rails, I've written up a post at http://ducktypelabs.com/using-scope-with-associations/

Defining scopes on your associations can come in handy for cleaning your code up and ensuring that business logic stays in one place. I was also motivated to write about it because there have been quite a few situations where I wanted to filter a group of records by given values of association records, for which scopes are useful.


Hey there @jamlevi, I recently wrote up an article about this based on your question at:


You're on the right path with fields_for and accepts_nested_attributes_for.

I did also include an example repo on GitHub for reference and to play around with. If the use case in the article doesn't match what you're looking for, be sure to let me know in the comments section and I'll try to help out, cheers!