0

I am attempting

get ":site_name", to: 'public_site#index' 

hoping that

get("/catsfrommars").should route_to("public_site#index")

Unfortunately I am getting the :site_name routed as an action:

No route matches {:controller=>"public_site", :action=>"/catsfrommars"}

I also tried

get "/:site_name", to: 'public_site#index' 
get "(:site_name)", to: 'public_site#index' 

And the :site_name parameter still gets routed as an action on the specified controller.

Any ideas on how to fix this and get :site_name as a parameter?

Edit: I am trying to do something similar to this: Rails Routing Question: Mapping Slugs/Permalinks Directly under Root? but with Rails4 syntax. Once I get it working, I'll use constraints to isolate the namespaced app routes.

Community
  • 1
  • 1
aaandre
  • 2,502
  • 5
  • 33
  • 46

1 Answers1

0

The route works properly, the issue was with rSpec.

{get: "/catsfrommars"}.should route_to(controller: "public_site", 
     action: "index", site_name: "catsfrommars")

resolved it, and more specifically moving the get into a block.

aaandre
  • 2,502
  • 5
  • 33
  • 46