我們有一個由rails 3.1.8開發的工具,可以將產品信息導出到ms字,然後產品所有者可以點擊我們應用中的鏈接來編輯產品詳細信息。ms word的打開鏈接
這裏是問題:當我們點擊鏈接的話,它會轉到主頁而不是編輯頁面。
所以我們用設計來進行認證,在路線:
devise_for :users do
get "login" => "devise/sessions#new"
get "logout" => "devise/sessions#destroy"
end
開發日誌:
Started GET "/products/24/edit" for 10.237.133.26 at 2012-12-17 15:24:49 +0800
Processing by ProductsController#edit as */*
Parameters: {"id"=>"24"}
Completed in 4ms
Session: {"as:products"=>{:list=>{}}, "input_device_type"=>"MOUSE", "hover_supported"=>true, "user_return_to"=>"/products/24/edit", "flash"=>#<ActionDispatch::Flash::FlashHash:0x00000006c80540 @used=#<Set: {}>, @closed=false, @flashes={:alert=>"You need to sign in or sign up before continuing."}, @now=nil>, "_csrf_token"=>"xvfpiA69SZas+iHoCy5NQRMOifXtomG3RoLaYvPQsSw="}
Started GET "https://stackoverflow.com/users/sign_in" for 10.237.133.26 at 2012-12-17 15:24:49 +0800
Processing by Devise::SessionsController#new as */*
Rendered devise/shared/_links.erb (0.1ms)
Rendered devise/sessions/new.html.erb within layouts/activescaffold (3.3ms)
Rendered layouts/_header.html.erb (50.0ms)
Rendered layouts/_menu.html.erb (3.4ms)
Rendered layouts/_footer.html.erb (0.0ms)
Completed 200 OK in 91ms (Views: 62.7ms | ActiveRecord: 3.3ms)
Started GET "https://stackoverflow.com/users/sign_in" for 10.237.133.26 at 2012-12-17 15:24:50 +0800
Processing by Devise::SessionsController#new as HTML
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 15 LIMIT 1
Redirected to http:// localhost:30033/
Completed 302 Found in 33ms
Session: {"input_device_type"=>"MOUSE", "hover_supported"=>true, "_csrf_token"=>"Pa8zGbsbms4EwRUO4G7MyJFv7ztKe33WICeY7qpYgeQ=", "warden.user.user.key"=>["User", [15], nil], "flash"=>#<ActionDispatch::Flash::FlashHash:0x00000006fec508 @used=#<Set: {}>, @closed=false, @flashes={:alert=>"You are already signed in."}, @now=nil>}
Started GET "/" for 10.237.133.26 at 2012-12-17 15:24:51 +0800
Processing by WelcomeController#index as HTML
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 15 LIMIT 1
Rendered welcome/index.html.erb within layouts/application (0.0ms)
Rendered layouts/_header.html.erb (3.8ms)
Rendered layouts/_menu.html.erb (3.6ms)
Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 45ms (Views: 14.0ms | ActiveRecord: 4.3ms)
有誰有更好的解決方案?
我試試這個提議的情況下很好地解決,似乎不工作:https://github.com/plataformatec/devise/wiki/How-To:-Redirect-back當前頁面後登錄,註銷,註冊,更新 –