我们有一个由 rails 3.1.8 开发的工具,可以将产品信息导出到 ms word,如果产品线有一些更新,产品所有者可以单击 word 中的链接在我们的应用程序中编辑产品详细信息。
问题是:当我们点击word中的链接时,它会转到主页而不是编辑页面。
所以我们使用 devise 在路由中执行身份验证:
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 "/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 "/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)
有人有更好的解决方案吗?