User updating of has_many :through associations
In my app, the administrator of a company defines a set of attributes to be associated with a location (for example, market size and geographical location). They also define which values are acceptable for a given attribute (only one for each attribute for each locati开发者_如何学运维on). Since there is not a fixed number of attributes, I am using HMT for this association. In effect, location.attributes contains the attributes associated with the location. I want, in the location view, to allow the user to select the values for each attribute. I want those values to then update the HMT association. I can only find the brute force approach of creating a hash with those attributes, populating select tags with the choices, and then processing the hash coming back to Update manually, assigning the selections made by the user to the HABTM collection (location.attributes = params[location][attributes]). This seems like something that is common enough that ROR should have a more built-in way to do this. Am I missing something obvious?
@Ingo had the correct answer, pointing me to the nested forms railcasts. Thanks!
精彩评论