Published in Uncategorized
.
A couple of days ago I posted about my has_many :through troubles. Going back and re-reading the section in the new AWDwR 2nd ed. I realized why it is important to be well rested when trying to solve a problem.
When I had read through that section the first time, I did not see what I just read, namely the simple straight forward solution to the problem I was having with creating a join record using a join model. Specifically the bottom half of page 339 demonstrates the solution to the problem I was having.
I mistakenly reported that the book did not discuss the problem at all and I just wanted to clear that up and say it actually did.
Still it is worth noting that a simple google search turns up a lot of instances of people struggling with how to use has_many :through, since it works differently that any of the other association declarations.
Sphere: Related Content
After getting some sleep and then re-reading my earlier post, I realized that I was as not as clear as I’d like to be about my problem with has_many :through.
Just about every example I found of how to use has_many :through showed how to use it to read data and most were explaining how to use it for polymorphic associations. What I needed was to know how to create the data for a non-polymorphic relationship. This highlights a problem with the Rails framework, and the one thing I miss from PHP. Documentation. When looking at the API, I frequently find areas that have no commentary at all, and other areas where the commentary is incomplete. A lot of people have hit brick walls because of this, more than one google for help on a specific problem brought me across a forum post or a blog post describing frustration at the lack of information in the API. Continue reading ‘has_many :through issue cont.’
Sphere: Related Content