[rspec-users] route_for and nested resources

Chris Olsen lists at ruby-forum.com
Wed Nov 21 16:10:56 EST 2007

I can't figure out how to make the updates to allow for the route_form
method to return a url that matches the expected.

Here is a sample
route_for(:controller => :task, :action => :new).should == "/task/new"

If a task has to be created for a user, how exactly do I do this.  The
following doesn't work:
route_for(:controller => :task, :action => :new, :user_id => 1).should
== "/users/1/task/new" (fails)
route_for(:controller => :task, :action => :new, :user_id => 1).should
== "/task/new?user_id=1" (passes)

Or do you just use:
new_user_task(1,1).should == "/users/1/task/new"

I haven't been able to find that much documentation on the route_for
method that lists any ways of creating the nested route url.

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list