Rob
2005-May-31 07:51 UTC
Please help a newbie: form helpers while iterating through a list
Hi all, I''m having real problems using form helpers for complex relationships. I have a table of users, and a table of subjects. A third table, ''interests'', comprises the following fields: id, user_id, subject_id, description. User has many interests; subjects has many interests; interest belongs to user and belongs to subject. So far so good. Now, for various reasons, the ''edit interests'' view has to be a single page. So I need to find a way to iterate through @user.interests, producing a <textarea> for each subject. I''m having two problems with this: 1) I can''t figure out how to get the interest.id into the form helper. What should the text_area helper look like? 2) What do I do about the fields that are empty? Let''s say that the user has already entered an interest for one subject, but not the others. When s/he enters interests for some of the other subjects, I will have a variety of ''new'' entries to contend with. So I suppose I also need to get the department_id into the form helper too. I tried adapting something like this: http://one.textdrive.com/pipermail/rails/2005-January/001888.html But without success. Please can someone help? Rob