开发者

Rails devise custom urls

开发者 https://www.devze.com 2023-01-24 12:00 出处:网络
I\'m aware that you can change the names of routes for devise, but I\'m looking to actually add something to a devise route, like so:

I'm aware that you can change the names of routes for devise, but I'm looking to actually add something to a devise route, like so:

match "users/sign_up/:invitation_token', :controller => 'registrations', :action => 'new'"

I've tried adding that line both directly above and directly below my devise routing declara开发者_如何学运维tion:

devise_for :users, :controllers => { :registrations => "registrations" }

But rails doesn't see the route. Is there a way that I can add a parameter to the devise generated URL?

Thanks


I'm assuming you're on rails 3 due to the use of the 'match' keyword. Try the following syntax

match 'users/sign_up/:invitation_token', :to => 'registrations#new'

Put this line below your devise_for line and you should be good to go.

And since your goals is to manage invitations, you'll probably want to check out https://github.com/scambra/devise_invitable (haven't tried it myself)


Still I was getting some routing error. This worked for me:

  devise_scope :user do 
    match "users/profile" => "sessions#show" 
  end
0

精彩评论

暂无评论...
验证码 换一张
取 消