Hi everyone,

I want to build a form following this idea:

I have Assignment, Activity, Task, AssignmentActivity, ActivityTask
and AssignmentActivityTask models
1 assignment has many activities and 1 activity has many tasks

(there's a many-to-many relation between:
Assignment - Activity
AssignmentActivity - Task,
and a One-to-many relation:
Activity - Task)
I've made the Assignment-Activity form using this idea:

and the form looks like this


<% form_for @assignment do |f|%>
<% Activity.all.each do |a|%>
<% check_box_tag "assignment[activity_ids][]", a.id,
@assignment.activity_ids.include?(a.id)%> | <% a.name%>

So it saves inside the assignment, all the activities that I've

The problem comes when I tried to add the ability to save task inside
this form. This is what I've tried


<% form_for @assignment do |f|%>
<% Activity.all.each do |a|%>
<%= check_box_tag "assignment[activity_ids][]", a.id,
@assignment.activity_ids.include?(a.id)%> | <%= a.name%> <br>
<% a.tasks.each do |t|%>
<%= check_box_tag "assignment[activity_ids][][]", t.id,
"Something here"%> | <%= t.task_name %><><br>

But I'm not sure how to write the line after the comment.

So when it saves it should save inside the assignment the activities
and also the tasks the I've checked

Is there a way of doing this?

Thanks in advance

Javier Q.

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
postedFeb 27, '12 at 3:51p
activeFeb 27, '12 at 3:51p

1 user in discussion

JavierQQ: 1 post



site design / logo © 2021 Grokbase