MrPizzaFace
MrPizzaFace

Reputation: 8086

Rails 4 routing with optional params?

I set an optional param in my signup route:

devise_scope :user do
  get '/signin', to: 'devise/sessions#new'
  get '/signup(/:sign_up_key)', to: 'users/registrations#new'
end

Before the optional param was there I could do:

signup_path

Rack routes shows:

signin GET    /signin(.:format)                   devise/sessions#new
       GET    /signup(/:sign_up_key)(.:format)    users/registrations#new

Now signup_path is no longer available? How do I get it back with the optional param there?

By the way I am routing like this:

<%= link_to '/signup' ... %>

Instead of:

<%= link_to signup_path ... %>

Would like to get access to the prefix back? Thanks!

Upvotes: 2

Views: 1310

Answers (1)

BroiSatse
BroiSatse

Reputation: 44725

Try adding as: :singup:

get '/signup(/:sign_up_key)', to: 'users/registrations#new', as: :signup

Upvotes: 3

Related Questions