How to pass a variable in Devise sign_up link
How can I pass a variable to my sign_up controller using Devise? I want to add the user开发者_StackOverflow中文版 chosen plan to the database on registration.
Thanks
You can add this in your routes.rb
match 'register' => redirect('/users/sign_up?plan=pro')
OR
match 'register/:plan' => redirect('/users/sign_up/{%plan}')
And create the matching controllers.
Get more routes info from here: http://guides.rubyonrails.org/routing.html#redirection
Alternatively, this can also be used https://github.com/plataformatec/devise/wiki/How-To:-Customize-routes-to-user-registration-pages
精彩评论