Nice examples! All these tips will certainly contribute to a clever and beautiful code. Thanks!
will this work if you have @projects, i.e multiple projects?
@bob, nope. If you have an array of projects you'll have to fetch the tasks for all those projects using a custom find of some sort.
Hi Ryan,
I have been checking your website for more has_many :through articles.
I have this question which I hope you could provide your insights, as I have been checking around but to-date still could not fully understand.
I would greatly appreciate if you could look at my code on http://railsforum.com/viewtopic.php?id=10204
I have these 2 tables: groups and users, where a group can have many users and an user can have many groups.
I have this third table, roles, which contains group_id, user_id, type. The field 'type' can be Administrator, Owner and Member. A user can play the role of Owner for a group but assume the role of member for another group. I use this table as Single Table Inheritance.
I want to do such query:
Based on a given user's id, I want to
display all the groups of this user, with the respective role for that group.
I have been reading and trying the associations. The last working association I tried is (assuming the user-id I want to check is 1):
User.find(1).roles.each do |role|
<%= role.group.name %>
end
Is that the way to perform such query?
Thank you, for your great effort in sharing your knowledge with others.
Thank you very much.
I have the same problem as weelkohO
would be nice to have a railcast with that specific problem ^___^
pls! ^_^
Is this really a Find Through Association or a has_many / belongs_to.
What about a many to many 'find through' association?
Thank you for this Railscast. Your work is slowly helping me understand the more interesting side of rails.
The on issue I felt would have been nice here would be how to use the @accounts in your view. This would have complete the information needed to create the HABTM. I.E. if we had a user with an account and wanted to pull up the account for the user as a view, how would one use this?
Thanks Again.
Thank you very much!
Your article is very useful!
A four year old little boy was at the doctor's office with his mother in the waiting room when he spotted a pregnant lady on the other side of the room. Having nothing better to do, he walks over to her and inquisitively asks "Why is your stomach so big?"
Although I can't agree with all you staded, I must confess I do love your way of writing.
The on issue I felt would have been nice here would be how to use the @accounts in your view. This would have complete the information needed to create the HABTM. I.E. if we had a user with an account and wanted to pull up the account for the user as a view. Great example. Just what I was looking for. Thanks!
Thanks for sharing your article. I really enjoyed it. I put a link to my site to here so other people can read it. My readers have about the same interets
Your work is slowly helping me understand the more interesting side of rails.
I agree with your Blog and I will be back to check it more in the future so please keep up your work. I love your content & the way that you write. It looks like you’ve been doing this for a while now, how long have you been blogging for?






