注册在当地工作,但不在Heroku上工作 [英] Sign Out working locally, but not working on Heroku
问题描述
所以我正在使用devise进行登录/注销。我注意到我的sign_out链接在本地工作正常,但即使在我添加,承诺和推送之后,Heroku也不会工作。
这是我看到的在我的Heroku日志
2014-04-23T22:16:09.987029 + 00:00 heroku [路由器]:at = info方法= GET path = / users / sign_out host = peace-atoll-4795.herokuapp.com request_id = 16559a9f-0cff-4179-8aeb-d393ae44de38 fwd =108.233.86.201dyno = web.1 connect = 60ms service = 34ms status = 404 bytes = 1616
请注意,它尝试使用GET方法退出何时被删除。为什么我的路线正确使用GET方法?
耙路线:
前缀动词URI模式控制器#动作
new_user_session GET /users/sign_in(.:format)devise / sessions#new
user_session POST / users / sign_in devise / sessions#创建
destroy_user_session DELETE /users/sign_out(.:format)devise / sessions#destroy
user_password POST /users/password(.:format)devise / passwords#create
new_user_password GET /users/password/new(.:format)devise / passwords#new
edit_user_password GET /users/password/edit(.:format)devise / passwords#edit
PATCH / users /password(.:format)devise / passwords#update
PUT /users/password(.:format)devise / passwords#update
devise.rb设置为...
config.sign_out_via =:删除
我的视图中的链接代码
<%if user_signed_in? %GT;
以< strong><%= current_user.email%>< / strong> ;.
<%= link_to'编辑个人资料',edit_user_registration_path,class => 'navbar-link'%> |
<%= link_to注销,destroy_user_session_path,方法::delete,:class => 'navbar-link'%>
<%else%>
<%= link_to注册,new_user_registration_path,class => 'navbar-link'%> |
<%= link_to登录,new_user_session_path,:class => 'navbar-link'%>
<%end%>
提前感谢您的任何资源或输入!
所以,正如预期的那样,我的路线是正确的,但我的应用程序无法访问 jquery_ujs
p>
jquery_ujs
帮助制作方法::delete
work。 / p>
为了提供正确的jquery_ujs路径,我添加了 gem'rails_12factor',group::production
到我的Gemfile并运行 bundle install
rails_12factor
也有助于服务Heroku的静态资产。
感谢@MichaelSzyndel了解有用的资源...
Rails 4 Heroku的资产管道: https://devcenter.heroku.com / articles / rails-4-asset-pipeline
So I'm using devise for login/logout. I noticed that my sign_out link is working just fine locally, but won't work on Heroku even after I've added, committed and pushed.
Here is what I see in my Heroku logs
2014-04-23T22:16:09.987029+00:00 heroku[router]: at=info method=GET path=/users/sign_out host=peaceful-atoll-4795.herokuapp.com request_id=16559a9f-0cff-4179-8aeb-d393ae44de38 fwd="108.233.86.201" dyno=web.1 connect=60ms service=34ms status=404 bytes=1616
Note that it tries to use the GET method to sign out when it should be DELETE. Why is it using the GET method when my routes are correct?
rake routes:
Prefix Verb URI Pattern Controller#Action
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
devise.rb setup as such...
config.sign_out_via = :delete
Link code from my view
<% if user_signed_in? %>
Logged in as <strong><%= current_user.email %></strong>.
<%= link_to 'Edit profile', edit_user_registration_path, :class => 'navbar-link' %> |
<%= link_to "Logout", destroy_user_session_path, method: :delete, :class => 'navbar-link' %>
<% else %>
<%= link_to "Sign up", new_user_registration_path, :class => 'navbar-link' %> |
<%= link_to "Login", new_user_session_path, :class => 'navbar-link' %>
<% end %>
Thanks ahead of time for any of your resources or input!
So, as expected my routes were correct, but my app was not able to access jquery_ujs
.
jquery_ujs
helps in making method: :delete
work.
In order to provide the correct path to jquery_ujs I added gem 'rails_12factor', group: :production
to my Gemfile and ran bundle install
rails_12factor
also helps in serving static assets in Heroku.
Thanks to @MichaelSzyndel for this helpful resource...
Rails 4 Asset Pipeline on Heroku: https://devcenter.heroku.com/articles/rails-4-asset-pipeline
这篇关于注册在当地工作,但不在Heroku上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!