简体   繁体   中英

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(

Nevermind, I didn't need to place a parameter inside the devise_for route declaration.

  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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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