Lee*_*lly 6 ruby ruby-on-rails devise turbolinks hotwire-rails
I've followed this GoRails video to get Devise working with hotwire-rails. I'm at a loss as to why my login error messages do not work the same way as in the video. The error messages work great on the registration form but on the login form I get this error:
Processing by Devise::SessionsController#create as TURBO_STREAM
Parameters: {"authenticity_token"=>"[FILTERED]", "user"=>{"email"=>"elvis@example.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"}
Completed 401 Unauthorized in 2ms (ActiveRecord: 0.0ms | Allocations: 406)
Run Code Online (Sandbox Code Playgroud)
As Chris suggests in the video I've edited my Devise initializer to look like this.
My package.json has @hotwired/turbo-rails": "^7.0.0-beta.5, but in Chris's source code for the episode it's beta.3 so that does not seem to be the problem.
What am I missing here?
我通过将所有闪存错误/通知统一为一个部分来实现此工作,而不是使用一个闪存通知部分和一个单独的表单错误块:
\n我把这个放在我的layouts/application.rb:
<%= render "shared/notices" %>\nRun Code Online (Sandbox Code Playgroud)\n该部分看起来像这样:
\n<% flash.each do |msg_type, message| %>\n <div class="alert">\n <div class="container">\n <button class="close" data-dismiss="alert"><span>\xc3\x97</span></button>\n <%= message %>\n </div>\n </div>\n<% end %>\nRun Code Online (Sandbox Code Playgroud)\n然后,我form_for的views/devise/sessions/new.html.erb看起来像这样:\n<%= form_for(resource, as: resources_name, url: session_path(resource_name)) do |f| %>