The same situation as in Rails link which POSTs in development GETs in production but there is no conclusion in that question, so I am trying as well:
I have the following in my view:
<%= link_to '✓'.html_safe, item_path(item), method: :patch, :class=>"item__buy-btn" %>
It generates the following HTML:
<a class="item__buy-btn" rel="nofollow" data-method="patch" href="/items/32">✓</a>
This is in my item controller (I do not have a item#show):
def update
item = Item.find(params[:id])
item.update(bought: true)
list = List.find(item.grocery_item_id)
receipt = Receipt.find(list.receipts.last.id)
receipt.close
item.update(grocery_item_id: receipt.id, grocery_item_type: receipt.class.name)
item.save
redirect_to request.referrer || root_url
end
And this is my items related routes:
items GET /items(.:format) items#index
POST /items(.:format) items#create
new_item GET /items/new(.:format) items#new
edit_item GET /items/:id/edit(.:format) items#edit
item GET /items/:id(.:format) items#show
PATCH /items/:id(.:format) items#update
PUT /items/:id(.:format) items#update
DELETE /items/:id(.:format) items#destroy
Clearly a POST:

Log says PATCH:
web_1 | Started PATCH "/items/33" for 172.21.0.1 at 2019- 05-05 19:29:31 +0000
web_1 | Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
web_1 | Processing by ItemsController#update as HTML
web_1 | Parameters: {"authenticity_token"=>"KmPf0fEDEs6Y2gUmC6Su9fdeVOg51AwCUUWyQBq14Gz0Fs6IRJ5cmmQdUETMbE+IMRTTGcfQPQ86x0rNzDSRHg==", "id"=>"33"}
And then in PRODUCTION:
I, [2019-05-05T18:27:22.439552 #1] INFO -- : [93c90971-1378-4e39-b6fb-8329dd46922e] Started GET "/" for 10.255.0.2 at 2019-05-05 18:27:22 +0000
I, [2019-05-05T18:27:22.440379 #1] INFO -- : [93c90971-1378-4e39-b6fb-8329dd46922e] Processing by HomeController#index as HTML
I, [2019-05-05T18:27:22.441694 #1] INFO -- : [93c90971-1378-4e39-b6fb-8329dd46922e] Rendering home/index.html.erb within layouts/application
I, [2019-05-05T18:27:22.443279 #1] INFO -- : [93c90971-1378-4e39-b6fb-8329dd46922e] Rendered home/index.html.erb within layouts/application (1.4ms)
I, [2019-05-05T18:27:22.444679 #1] INFO -- : [93c90971-1378-4e39-b6fb-8329dd46922e] Completed 200 OK in 4ms (Views: 3.0ms)
I, [2019-05-05T18:49:37.971732 #1] INFO -- : [5f452d24-80c5-44dc-bd8a-cb2be0aa5f14] Started GET "/items/7" for 10.255.0.2 at 2019-05-05 18:49:37 +0000
F, [2019-05-05T18:49:37.973154 #1] FATAL -- : [5f452d24-80c5-44dc-bd8a-cb2be0aa5f14]
F, [2019-05-05T18:49:37.973209 #1] FATAL -- : [5f452d24-80c5-44dc-bd8a-cb2be0aa5f14] AbstractController::ActionNotFound (The action 'show' could not be found for ItemsController):
F, [2019-05-05T18:49:37.973237 #1] FATAL -- : [5f452d24-80c5-44dc-bd8a-cb2be0aa5f14]
F, [2019-05-05T18:49:37.973274 #1] FATAL -- : [5f452d24-80c5-44dc-bd8a-cb2be0aa5f14] actionpack (5.2.3) lib/abstract_controller/base.rb:129:in `process'

What could cause this behavior? Is there any relevant information I am missing in this post?
EDIT:
As per ser tadmans answer, it was apparently about the javascript. It failed on precompile due to a '#' comment in one of the files.
This usually happens because the Rails UJS JavaScript library failed to load and the data attributes it injects are ignored.
Check that the UJS library loaded. If you're using Sprockets, ensure that the rails-ujs "comment" line in application.js is present.
If you're running in production mode you need to ensure that your assets are properly compiled. This can be done with rake assets:precompile in the prouction deployment location for Rails 3 through 5.2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With