Search code examples
ruby-on-railsurlhelper

Why is url helper in rails putting a "." instead of a "/" in path?


In my app I am working on allowing users to send invitations. The invites have tokens. And in the emails I am linking to a signup page with the token in the path. In the mailer's controller I am using:

new_user_registration_url(@invitation.token)

as I saw Ryan Bates do in this railscast. But it appears to be outputting this format:

http://localhost:3000/signup.4a4aebcde29738a39c7f447f58817e49cf9b4cf4

Why is there a "." instead of a "/"?

Update:

I'm using devise and here are the relevant routes. I am not to confident about these; I had struggled a little with it but these seemed to work:

  devise_scope :user do
    get '/signup/:invitation_token' => "registrations#new", :as => :new_user_registration
  end
  devise_for :users, :controllers => { :registrations => "registrations"}, :skip => [:registrations]
  as :user do
    get '/users/cancel' => 'devise/registrations#cancel', :as => :cancel_user_registration
    post '/users' => 'devise/registrations#create', :as => :user_registration
    get '/signup' => 'registrations#new', :as => :new_user_registration
    get '/users/edit' => 'devise/registrations#edit', :as => :edit_user_registration
    put '/users' => 'devise/registrations#update'
    delete '/users' => 'devise/registrations#destroy'
  end

Solution

  • Wihout routes.rb it's hard to tell but it seems the author has something like:

    #in routes.rb
    get 'signup' => 'controller#action', as: :new_user_registration
    

    but has to have:

    get 'signup/:token' => 'controller#action', as: :new_user_registration
    

    Checking:

    # in console
    app.new_user_registration_path('ToKeN') # => "/signup/ToKeN"