This app github
<% = link_to "Login with Google account", "/ users/auth/google_oauth2/callback", method:: post%>

I wrote like this


Rails.application.routes.draw do
  root to:'drinks # index'
  get'/ login', to:'sessions # new'
  post'/ users/auth /: provider/callback', to:'sessions # create'

Is described as

No route matches [GET] "/ users/auth/google_oauth2/callback"

And get request is accepted

Even with the verification tool, the generated a link did not have method = post.

What I tried
Login with Google Account

I could do it.
Why doesn't link_to work?

  • Answer # 1

    It's strange ...

    Maybe this is the reason.

    Because it meansapp/assets/javascripts/application.js
    Why don't you check it out?

    // = require jquery_ujs
    It seems that the same phenomenon will occur if there is no description.


    I confirmed github.
    I'm sorry, rails6 seems to have a different directory structure for the app ...
    The correspondence method in case of 6 seems to be different ...

    I can't say anything because I've never built an app in 6, but it's probably the location of the file.app/javascript/packs/application.jsI wonder if it will be.

    Further notes

    I saw the commit history on github.
    Delete unnecessary description
    Is deleted at the time of commitrails-ujsBut,jquery-ujsI remember that it had the same effect as.

    As a test,rails-ujsWhy don't you put it back (restored)?