Hobo / hobo

The web app builder for Rails (moved from tablatom/hobo)

Home Page:http://hobocentral.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

front_controller generator generates duplicate "site_search_post" routes

hbaragar opened this issue · comments

When running the following command:
hobo g front_controller admin::front
the following routes get added (along with one more):

post 'search' => 'admin/front#search', :as => 'site_search_post'
get 'search' => 'admin/front#search', :as => 'site_search'

which confict with:

post 'search' => 'front#search', :as => 'site_search_post'
get 'search' => 'front#search', :as => 'site_search'

as indicated by the following error lines:

<path-to>/ruby/gems/2.1.0/gems/actionpack-4.0.8/lib/action_dispatch /routing/route_set.rb:430:in `add_route': Invalid route name, already in use: 'site_search_post'  (ArgumentError)
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here: 
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created

Should these routes be added for subsites?
If so, should they be put in a namespace as follows:

namespace :admin do
  post 'search' => 'admin/front#search', :as => 'site_search_post'
  get 'search' => 'admin/front#search', :as => 'site_search'
end

I am not sure that this code would work as intended (I don't even know if it compiles).

You are right, thanks for the report.