Reputation: 322
I'm building a clone for Tinder using Rails here. The app can run locally without any error. I'm using Rails 4.2.6
When I deploy the app on Heroku, the function like/dislike for the app doesn't work, but only on Chrome. In the logs file it says no route
I tried to use Safari and it can run without any problem.
I have cleared the cache
I took a look at Heroku logs file and I found that the method for Chrome is GET while on Safari it's POST.
Here's the logs (I removed the time stamp)
On chrome:
at=info method=GET path="/users/4/like_user" host=tinderusth.herokuapp.com request_id=25ad4d9f-f37c-4386-8192-0ba81e7431af fwd="42.112.242.134" dyno=web.1 connect=1ms service=41ms status=404 bytes=1829
Started GET "/users/4/like_user" for 42.112.242.134 at 2016-05-30 14:11:32 +0000
ActionController::RoutingError (No route matches [GET] "/users/4/like_user")
On Safari:
at=info method=POST path="/users/9/like_user" host=tinderusth.herokuapp.com request_id=9b6951a4-9fc1-4d18-b43e-e0594bf82e6a fwd="42.112.242.134" dyno=web.1 connect=2ms service=68ms status=302 bytes=1026
User Load (2.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 2]]
Parameters: {"authenticity_token"=>"Wz+R/8pl+/R7vlwex6fL1PWgVUQmdqHj3FwCjtu75GQMk7sQ6Q4gwbfUAILQElAFJA8DtmPSf3jh9LrQpTMYYQ==", "id"=>"9"}
app[web.1]: Started POST "/users/9/like_user" for 42.112.242.134 at 2016-05-30 14:12:04 +0000
app[web.1]: User Load (4.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 9]]
My route.rb: (I use devise gem)
devise_for :users
resources :posts
resources :users do
member do
post :like_user, :superlike_user
end
end
resources :profiles
resources :matches do
member do
delete :unlike_user
end
end
root 'users#index'
Both rendered the same view:
<a class="users-button like-button" id="like_user_1" rel="nofollow" data-method="post" href="/users/1/like_user">
<span title="Like this user" class="fa fa-thumbs-up hvr-bounce-in" aria-hidden="true">
</span>
</a>
Thank you for your helps.
Upvotes: 0
Views: 81
Reputation: 583
Looks like Chrome doesn't interpret your data-method: :post
.
Chrome : Started GET
Safari: Started POST
Try to do this with a button_to
which enables you to bypass these limitations. (http://apidock.com/rails/ActionView/Helpers/UrlHelper/button_to)
Upvotes: 1