I have namespace in my routes.rb
namespace :businesses do
resources :registration
end
My controller is in a subdirectory businesses
If you have namespaced routes the best way is:
class Admin::BusinessesController < ApplicationController
def new
@business = Business.new
end
end
in routes.rb:
namespace :admin do
resources :businesses
end
In view:
form_for [:admin, @business] do |f|...
The Docs: http://guides.rubyonrails.org/form_helpers.html section 2.3.1 Dealing with Namespaces
Regarding your case:
In routes.rb everything is o'k. In the view you should write url explicitly because you have variable in controller other than controller name:
form_for @business, :url => business_registration_path do |f|...
I suppose that in businesses/registration_controller you have something like this:
class Businesses::RegistrationController < ApplicationController
def new
@business = Business.new
end
end
And one remark: I wouldn't create registration_controller for registering a new business. I think that keeping business related actions in business_controller is much clearer.
Actually, I think there is a better solution.
form_for [:admin, @business]
the issue with giving a url is that if you abstract the form out as a partial view, you'll need to deal with "create" and "update" situations. They points to different urls, and ends up with providing the @url
in controller.