Strange Rails Authentication Issue

2019-07-15 10:19发布

I'm using the RESTful authentication Rails plugin for an app I'm developing. I'm having a strange issue I can't get to the bottom of. Essentially, the first time I log into the app after a period of inactivity (the app is deployed in production, but only being used by me), I will be brought to a 404 page, but if I go back to the home page and log in again, everything works according to plan. Any ideas?

2条回答
贪生不怕死
2楼-- · 2019-07-15 10:58

Please check your routes.

Not all routes are created equally. Routes have priority defined by the order of appearance of the routes in the config/routes.rb file. The priority goes from top to bottom. The last route in that file is at the lowest priority and will be applied last. If no route matches, 404 is returned.

More info: http://api.rubyonrails.org/classes/ActionController/Routing.html

查看更多
做自己的国王
3楼-- · 2019-07-15 11:02

I'm using a slightly modified version of that plugin so I'm not 100% sure that this will be the same for you, but for me the default is to redirect to the root path, or the page you were trying to get to if there is one. (check your lib/authenticated_system.rb to see your default) If you don't have map.root defined in your routes, I believe that would cause the error you're describing -- it wouldn't find root_path at first but if you tried "from" a page in your app it would redirect to that page.

Let us know what happens with this one if you would, I'm curious to see what this ends up being in case I run into it in the future. :)

查看更多
登录 后发表回答