简体   繁体   English

Rails路由设计参数

[英]rails routing devise parameters

I'm trying to modify an existing devise route to hold parameters 我正在尝试修改现有的设计路线以保存参数

Here is the working route: 这是工作路线:

  devise_for :contributors, controllers: {registrations: 'contributors/registrations', confirmations: 'contributors/confirmations'}

the working path: 工作路径:

  <p><a href="<%= new_contributor_registration_path%>" class="btn btn-lg btn-primary" role="button">Create Account</a></p>

I need to be able to pass a parameter with it. 我需要能够通过它传递参数。 Is there a simple way to do this? 有没有简单的方法可以做到这一点?

I was thinking of doing something like this: 我正在考虑做这样的事情:

  devise_for :contributors, controllers: {registrations: 'contributors/registrations(/:contributor_type)', confirmations: 'contributors/confirmations'}

  <p><a href="<%= new_contributor_registration_path(contributor_type: 'teacher') %>" class="btn btn-lg btn-primary" role="button">Create Account</a></p>

but no luck, it only returns this error: wrong constant name Registrations( 但没有运气,它只会返回此错误:错误的常量名Registrations(

Nevermind, I didn't need to place a parameter inside the devise_for route declaration. 没关系,我不需要在devise_for路由声明中放置参数。

  devise_for :contributors, controllers: {registrations: 'contributors/registrations', confirmations: 'contributors/confirmations'}

this works just fine with 这适用于

<p><a href="<%= new_contributor_registration_path(contributor_type: 'teacher') %>" class="btn btn-lg btn-primary" role="button">Create Account</a></p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM