# ActionController::RoutingError -\> Functional Tests and :path\_prefix in routes.rb

**URL:** <https://www.ruby-forum.com/t/actioncontroller-routingerror-functional-tests-and-path-prefix-in-routes-rb/167852>\
**Category:** Rails\
**Created:** [May 13, 2009, 9:59am UTC](https://www.ruby-forum.com/t/actioncontroller-routingerror-functional-tests-and-path-prefix-in-routes-rb/167852 "2009-05-13T09:59:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pablo\_Alonso\_GarcSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b4bc9f/32.png) [@Pablo\_Alonso\_GarcSS](https://www.ruby-forum.com/u/Pablo_Alonso_GarcSS)\
**Post date:** [May 13, 2009, 9:59am UTC](https://www.ruby-forum.com/t/actioncontroller-routingerror-functional-tests-and-path-prefix-in-routes-rb/167852/1 "2009-05-13T09:59:18Z")

</div>

Hi,

I’m trying to write a test for my ProfilesController, which I mapped  
in my routes.rb, using:

map.resource :profile, :path\_prefix =\> ‘:account’

This way, I have routes like:

```
           profile POST /:account/profile

```

{:controller=\>“profiles”, :action=\>“create”}  
formatted\_profile POST /:account/profile.:format  
{:controller=\>“profiles”, :action=\>“create”}  
new\_profile GET /:account/profile/new  
{:controller=\>“profiles”, :action=\>“new”}  
formatted\_new\_profile GET /:account/profile/new.:format  
{:controller=\>“profiles”, :action=\>“new”}  
edit\_profile GET /:account/profile/edit  
{:controller=\>“profiles”, :action=\>“edit”}  
formatted\_edit\_profile GET /:account/profile/edit.:format  
{:controller=\>“profiles”, :action=\>“edit”}  
GET /:account/profile  
{:controller=\>“profiles”, :action=\>“show”}  
GET /:account/profile.:format  
{:controller=\>“profiles”, :action=\>“show”}  
PUT /:account/profile  
{:controller=\>“profiles”, :action=\>“update”}  
PUT /:account/profile.:format  
{:controller=\>“profiles”, :action=\>“update”}  
DELETE /:account/profile  
{:controller=\>“profiles”, :action=\>“destroy”}  
DELETE /:account/profile.:format  
{:controller=\>“profiles”, :action=\>“destroy”}

My problem is that, when running the following test:

def test\_new  
get :new  
assert\_redirected\_to new\_session\_path  
end

I get the error:

test\_new(ProfilesControllerTest):  
ActionController::RoutingError: No route matches  
{:controller=\>“profiles”, :action=\>“new”}  
…

I can’t understand why ‘get :new’ can’t find that route and, on the  
other hand, ‘rake routes’ does recognize it.

This part of my application works fine (including :url =\> {:controller  
=\> ‘profiles’, :action =\> ‘create’} in the form\_for tags). Though, I  
don’t know how to write the proper tests. Do I have to pass any extra  
parameter to ‘get’? Do you think is it a bit silly to use this  
mapping?

Thanks in advance,

Pablo.
