Hello all!
I have the following models:
Document belongs to a Task and to a Documentgroup and I want to select the
Task that Document belongs to using a link where I can select the Task, but
I also want to allow the user to select the Documentgroup using in the same
way. How can I maintain the document state between these requests?
Here is the code:
Models:
class Document < ActiveRecord::Base
  belongs_to :task
  belongs_to :documentgroup
end
class Task < ActiveRecord::Base
end
class Documentgroup < ActiveRecord::Base
end
Views:
edit view:
<%= start_form_tag :action => "update" %>
<%= text_field_tag("name", @document.name) %>
<%= text_field_tag("description", @document.description) %>
<%= text_field_tag("task", @task.name) %>
<%= link_to "Select", :action => ''select_task''
%>
<%= text_field_tag("documentgroup", @documentgroup.name) %>
<%= link_to "Select", :action =>
''select_documentgroup'' %>
<%= submit_tag "Change", { ''name'' =>
''change''} %>
<%= end_form_tag %>
select_task view:
<table>
<% for task in @tasks %>
<tr><td><%= task.name %></td><td><%= link_to
"Select", :action => "edit",
:value => task.id %></td></tr>
<% end %>
</table>
select_documentgroup view:
<table>
<% for documentgroup in @documentgroups %>
<tr><td><%= documentgroup.name %></td><td><%=
link_to "Select", :action =>
"edit", :value => documentgroup.id %></td></tr>
<% end %>
</table>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails