Ruby on rails 设计并添加第二组嵌套管线
我正在用Desive 3运行Rails 4应用程序,我想为Desive设置一组辅助路由。我有一个Ruby on rails 设计并添加第二组嵌套管线,ruby-on-rails,ruby-on-rails-4,devise,routing,Ruby On Rails,Ruby On Rails 4,Devise,Routing,我正在用Desive 3运行Rails 4应用程序,我想为Desive设置一组辅助路由。我有一个Portal模型,它代表一个独特的子站点,但共享相同的核心用户群。我希望能够将用户发送到类似于/portals/:portal\u id/users/sign\u in的路由,并使其行为与designe使用designe\u for:users创建的默认/users/sign\u in路由相同。我该怎么做 以下是我的路线: MyApp::Application.routes.draw do d
Portal
模型,它代表一个独特的子站点,但共享相同的核心用户群。我希望能够将用户发送到类似于/portals/:portal\u id/users/sign\u in
的路由,并使其行为与designe使用designe\u for:users
创建的默认/users/sign\u in
路由相同。我该怎么做
以下是我的路线:
MyApp::Application.routes.draw do
devise_for :users, :controllers => {:registrations => "registrations"}
root 'general#home'
resources :portals, controller: 'portals/general' do
member do
root 'portals/general#home'
end
end
end
我还有一个RegistrationController
,它覆盖默认的Desive控制器,如下所示:
class Portals::RegistrationsController < RegistrationsController
layout 'portals/layouts/application'
def create
@portal = Portal.friendly.find(params[:id])
build_resource(sign_up_params)
resource_saved = resource.save
yield resource if block_given?
if resource_saved
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_flashing_format?
sign_up(resource_name, resource)
redirect_to :back
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
# respond_with(resource, location: root_path)
flash[:notice] = resource.errors.full_messages.first
redirect_to root_portal_path(resource)
end
end
end
类门户::RegistrationController