<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jan 27, 2008, at 8:05 PM, David Chelimsky wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Nov 21, 2007 3:10 PM, Chris Olsen &lt;<a href="mailto:lists@ruby-forum.com">lists@ruby-forum.com</a>&gt; wrote:<br><blockquote type="cite">I can't figure out how to make the updates to allow for the route_form<br></blockquote><blockquote type="cite">method to return a url that matches the expected.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Here is a sample<br></blockquote><blockquote type="cite">route_for(:controller =&gt; :task, :action =&gt; :new).should == "/task/new"<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">If a task has to be created for a user, how exactly do I do this. &nbsp;The<br></blockquote><blockquote type="cite">following doesn't work:<br></blockquote><blockquote type="cite">route_for(:controller =&gt; :task, :action =&gt; :new, :user_id =&gt; 1).should<br></blockquote><blockquote type="cite">== "/users/1/task/new" (fails)<br></blockquote><blockquote type="cite">route_for(:controller =&gt; :task, :action =&gt; :new, :user_id =&gt; 1).should<br></blockquote><blockquote type="cite">== "/task/new?user_id=1" (passes)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Or do you just use:<br></blockquote><blockquote type="cite">new_user_task(1,1).should == "/users/1/task/new"<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I haven't been able to find that much documentation on the route_for<br></blockquote><blockquote type="cite">method that lists any ways of creating the nested route url.<br></blockquote><br>It uses ActionController::Routing::Routes.generate, which is equally<br>un-documented :(<br><br>You've got a singular task controller (instead of tasks), so I'm not<br>sure how that's affecting things. I can tell you that if you do this:<br><br>route_for(:controller =&gt; 'tasks', :action =&gt; 'new', :user_id =&gt;<br>'2').should == '/users/2/tasks/new'<br><br>It will pass when your routes.rb has this:<br><br>map.resources :users do |users|<br> &nbsp;users.resources :tasks<br>end<br><br>Give that a whirl.<br><br>Cheers,<br>David</div></blockquote><br></div><div><br class="webkit-block-placeholder"></div><div>Thanks for the further&nbsp;explanation&nbsp;David! I could've sworn that I tried this, but sure enough, it works like a charm.</div><div><br class="webkit-block-placeholder"></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; ">Thanks!</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Verdana; min-height: 17px; "><b></b><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Verdana; "><b>Matt Darby, M.S.</b></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Verdana; ">IT Manager / Lead Web Developer</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Verdana; min-height: 15px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Verdana; color: rgb(255, 0, 0); ">Dynamix Engineering Ltd.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Verdana; ">1108 City Park Ave.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Verdana; ">Columbus, OH 43206</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Verdana; ">Cell: (614) 403-5289</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Verdana; "><a href="http://www.dynamix-ltd.com">www.dynamix-ltd.com</a></div></div><div><br class="webkit-block-placeholder"></div></body></html>