Ruby on Rails HTTP 基本身份验证
我刚刚开始学习 Ruby on Rails,有一个新手问题,到目前为止我还找不到答案。我有一个使用 HTTP 基本身份验证的小型应用程序,并且我认为有一些设计元素,我只想在请求经过身份验证时显示这些元素。我如何访问这些信息?
I am just starting to learn Ruby on Rails and have a newbie question that I have so far been unable to find the answer for. I have a small app that uses HTTP basic authentication and I have design elements in my view that I only want to display if the request is authenticated. How can I access this information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用在会话期间存储数据的会话哈希( http ://www.tutorialspoint.com/ruby-on-rails/rails-session-cookies.htm)我建议使用以下教程和 Http Basic Auth 来生成表单:railscasts.com/episodes/21 -super-simple-authentication
这是一些您可以使用
application_controller 的代码
You can use the session hash which store data during your session( http://www.tutorialspoint.com/ruby-on-rails/rails-session-cookies.htm) I will recomend using the following tutorial with Http Basic Auth for generating the form: railscasts.com/episodes/21-super-simple-authentication
heres some code you could use
application_controller