Redirect_to需要输入

时间:2018-01-17 21:39:45

标签: ruby-on-rails redirecttoaction

在rails控制器中

def destroy
  cookies.delete(:auth_token)
  redirect_to root_path, :alert=> "Logged Out"
end

它转到空白页面。我必须按[Enter键]转到根页面 为什么以及如何解决它。 此问题与之前的Q:How to replace render inline for rails 5有关,因此我通过使用redirect_to来避免它,然后导致此问题。 现在我不能同时使用内联替换和redirect_to for Rails 5.2

rails routes:

[t1-250520]$ rails -v
Rails 5.2.0.beta2
[MacBook ~/mygem/test/t1-250520]  
[t1-250520]$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
[MacBook ~/mygem/test/t1-250520]  
[t1-250520]$ rails routes
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1-compliant syntax, but you are running 2.5.0.
/Users/kul/.rvm/gems/ruby-2.5.0/gems/unparser-0.1.16/lib/unparser/emitter/literal/primitive.rb:41: warning: constant ::Fixnum is deprecated
/Users/kul/.rvm/gems/ruby-2.5.0/gems/unparser-0.1.16/lib/unparser/emitter/literal/primitive.rb:42: warning: constant ::Bignum is deprecated
             Prefix Verb   URI Pattern                         Controller#Action
            samples GET    /samples(.:format)                  samples#index
                    POST   /samples(.:format)                  samples#create
         new_sample GET    /samples/new(.:format)              samples#new
        edit_sample GET    /samples/:id/edit(.:format)         samples#edit
             sample GET    /samples/:id(.:format)              samples#show
                    PATCH  /samples/:id(.:format)              samples#update
                    PUT    /samples/:id(.:format)              samples#update
                    DELETE /samples/:id(.:format)              samples#destroy
        pages_index GET    /pages/index(.:format)              pages#index
           ckeditor        /ckeditor                           Ckeditor::Engine
                    POST   /auth/:provider/callback(.:format)  sessions#create
                    GET    /auth/:provider/callback(.:format)  sessions#create
             logout GET    /logout(.:format)                   sessions#destroy
      jinda_pending GET    /jinda/pending(.:format)            jinda#pending
       jinda_status GET    /jinda/status(.:format)             jinda#status
       jinda_search GET    /jinda/search(.:format)             jinda#search
          jinda_doc GET    /jinda/doc(.:format)                jinda#doc
         jinda_logs GET    /jinda/logs(.:format)               jinda#logs
  jinda_ajax_notice GET    /jinda/ajax_notice(.:format)        jinda#ajax_notice
         jinda_init GET    /jinda/init(.:format)               jinda#init
          jinda_run GET    /jinda/run(.:format)                jinda#run
       jinda_run_do GET    /jinda/run_do(.:format)             jinda#run_do
     jinda_run_form GET    /jinda/run_form(.:format)           jinda#run_form
     jinda_end_form GET    /jinda/end_form(.:format)           jinda#end_form
                    POST   /jinda/pending(.:format)            jinda#index
                    POST   /jinda/end_form(.:format)           jinda#end_form
        articles_my GET    /articles/my(.:format)              articles#my
           articles GET    /articles(.:format)                 articles#index
                    POST   /articles(.:format)                 articles#create
        new_article GET    /articles/new(.:format)             articles#new
       edit_article GET    /articles/:id/edit(.:format)        articles#edit
            article GET    /articles/:id(.:format)             articles#show
                    PATCH  /articles/:id(.:format)             articles#update
                    PUT    /articles/:id(.:format)             articles#update
                    DELETE /articles/:id(.:format)             articles#destroy
         identities GET    /identities(.:format)               identities#index
                    POST   /identities(.:format)               identities#create
       new_identity GET    /identities/new(.:format)           identities#new
      edit_identity GET    /identities/:id/edit(.:format)      identities#edit
           identity GET    /identities/:id(.:format)           identities#show
                    PATCH  /identities/:id(.:format)           identities#update
                    PUT    /identities/:id(.:format)           identities#update
                    DELETE /identities/:id(.:format)           identities#destroy
           sessions GET    /sessions(.:format)                 sessions#index
                    POST   /sessions(.:format)                 sessions#create
        new_session GET    /sessions/new(.:format)             sessions#new
       edit_session GET    /sessions/:id/edit(.:format)        sessions#edit
            session GET    /sessions/:id(.:format)             sessions#show
                    PATCH  /sessions/:id(.:format)             sessions#update
                    PUT    /sessions/:id(.:format)             sessions#update
                    DELETE /sessions/:id(.:format)             sessions#destroy
    password_resets GET    /password_resets(.:format)          password_resets#index
                    POST   /password_resets(.:format)          password_resets#create
 new_password_reset GET    /password_resets/new(.:format)      password_resets#new
edit_password_reset GET    /password_resets/:id/edit(.:format) password_resets#edit
     password_reset GET    /password_resets/:id(.:format)      password_resets#show
                    PATCH  /password_resets/:id(.:format)      password_resets#update
                    PUT    /password_resets/:id(.:format)      password_resets#update
                    DELETE /password_resets/:id(.:format)      password_resets#destroy
        jinda_index GET    /jinda(.:format)                    jinda#index
          new_jinda GET    /jinda/new(.:format)                jinda#new
               root GET    /                                   jinda#index

Routes for Ckeditor::Engine:
        pictures GET    /pictures(.:format)             ckeditor/pictures#index
                 POST   /pictures(.:format)             ckeditor/pictures#create
         picture DELETE /pictures/:id(.:format)         ckeditor/pictures#destroy
attachment_files GET    /attachment_files(.:format)     ckeditor/attachment_files#index
                 POST   /attachment_files(.:format)     ckeditor/attachment_files#create
 attachment_file DELETE /attachment_files/:id(.:format) ckeditor/attachment_files#destroy

在终端:(无错误)

Started GET "/" for 127.0.0.1 at 2018-01-17 17:26:16 -0600
Processing by JindaController#index as HTML
  Rendering jinda/index.html.haml within layouts/application
  Rendered jinda/index.html.haml within layouts/application (8.0ms)
MONGODB | localhost:27017 | t1est250520_development.find | STARTED | {"find"=>"users", "filter"=>{"auth_token"=>"RqZJCKLfrWr5bhuqD20Irg"}, "sort"=>{"_id"=>1}, "limit"=>1, "singleBatch"=>true}
MONGODB | localhost:27017 | t1est250520_development.find | SUCCEEDED | 0.001296s
MONGODB | localhost:27017 | t1est250520_development.find | STARTED | {"find"=>"jinda_modules", "filter"=>{}, "sort"=>{"seq"=>1}}
MONGODB | localhost:27017 | t1est250520_development.find | SUCCEEDED | 0.0029920000000000003s
MONGODB | localhost:27017 | t1est250520_development.find | STARTED | {"find"=>"jinda_services", "filter"=>{"module_id"=>BSON::ObjectId('5a53c22651d2f5a66b4eae3c')}, "sort"=>{"seq"=>1}}
MONGODB | localhost:27017 | t1est250520_development.find | SUCCEEDED | 0.001562s
MONGODB | localhost:27017 | t1est250520_development.find | STARTED | {"find"=>"jinda_services", "filter"=>{"module_id"=>BSON::ObjectId('5a53c22651d2f5a66b4eae41')}, "sort"=>{"seq"=>1}}
MONGODB | localhost:27017 | t1est250520_development.find | SUCCEEDED | 0.001798s
MONGODB | localhost:27017 | t1est250520_development.find | STARTED | {"find"=>"jinda_services", "filter"=>{"module_id"=>BSON::ObjectId('5a53c22651d2f5a66b4eae46')}, "sort"=>{"seq"=>1}}
MONGODB | localhost:27017 | t1est250520_development.find | SUCCEEDED | 0.001582s
MONGODB | localhost:27017 | t1est250520_development.find | STARTED | {"find"=>"jinda_services", "filter"=>{"module_id"=>BSON::ObjectId('5a53c22651d2f5a66b4eae48')}, "sort"=>{"seq"=>1}}
MONGODB | localhost:27017 | t1est250520_development.find | SUCCEEDED | 0.0015429999999999999s
MONGODB | localhost:27017 | t1est250520_development.find | STARTED | {"find"=>"jinda_services", "filter"=>{"module_id"=>BSON::ObjectId('5a53c22651d2f5a66b4eae4b')}, "sort"=>{"seq"=>1}}
MONGODB | localhost:27017 | t1est250520_development.find | SUCCEEDED | 0.0019909999999999997s
MONGODB | localhost:27017 | t1est250520_development.find | STARTED | {"find"=>"jinda_services", "filter"=>{"module_id"=>BSON::ObjectId('5a53c22651d2f5a66b4eae51')}, "sort"=>{"seq"=>1}}
MONGODB | localhost:27017 | t1est250520_development.find | SUCCEEDED | 0.001495s
MONGODB | localhost:27017 | t1est250520_development.find | STARTED | {"find"=>"jinda_services", "filter"=>{"module_id"=>BSON::ObjectId('5a53c22651d2f5a66b4eae53')}, "sort"=>{"seq"=>1}}
MONGODB | localhost:27017 | t1est250520_development.find | SUCCEEDED | 0.0015329999999999999s
  Rendered jinda/_menu_mm.haml (81.6ms)
  Rendered jinda/_menu.haml (97.7ms)
  Rendered jinda/_static.haml (6.4ms)
  Rendered layouts/jqm/_full.haml (173.2ms)
Completed 200 OK in 205ms (Views: 199.8ms)

Chrome Inspect(无错误) enter image description here

0 个答案:

没有答案