Hello,
I'm having trouble workign with two models, specifically passing the id of my "Tools" model to New controller of my task model.
I am creating a page that keeps track of tools we are building in our group. For each tool, there can be several tasks associated with completing the code/process of the tool. I have a model for tool ("tools") and a model for tasks ("tooltasks"). On the tools view, each tool is listed out in table format. Next to each tool is a button/link called "add task". When the user clicks this button, I would like to bring up the tooltasks#new view with the tool.id (or just tool passed to the form). This is where its not working and i'm stuck. Any help out there?
offending code:
---> tools main page = "index.html.erb" <div id="tool-list"> <% for tool in @tools %> <tr valign="top" class="<%=cycle("tool-line-odd","tool-line-even") %>"> <tr> <td width="15%" valign="top" class="tool-title"><%=link_to tool.title, tool %></td> <td width="15%" valign="top" class="tool-title"><%=h tool.description %></td> <td width="15%" valign="top" class="tool-title"><%=h tool.status %></td> <td width="15%" valign="top" class="tool-title"><%=h tool.priority %></td> <td width="15%" valign="top" class="tool-title"><%=h tool.owner %></td> <td width="15%" valign="top" class="tool-title"><%=h tool.eta %></
<td valign="top"><%= button_to 'Add Task', new_tooltask_path,:id => tool.id %></td> <td valign="top"><%= button_to 'Edit', edit_tool_path(tool) %></
<td valign="top"><%= button_to 'Destroy', tool, :confirm => 'Are you sure?', :method => :delete %></td> </tr> <% end %> </table> </div>
tooltasks_controller.rb def new @tooltask = Tooltask.new
# is this the problem??? @tool = Tool.find(params[:id])
respond_to do |format| format.html # new.html.erb format.xml { render :xml => @tooltask } end end
What's going on? What am I missing? thanks for any help
Dave