libus[development]> Hanami.app.config.middleware
=> #<Hanami::Slice::Routing::Middleware::Stack:0x00007f7d85c940f0
@namespaces=[Hanami::Middleware],
@stack=
{"/"=>
[[Warden::Manager, [], {}, #<Proc:0x00007f7d85a695a0 /home/mrimp/workspace/libus/config/app.rb:14>],
[Hanami::Middleware::BodyParser, [:form], {}, nil],
[Rack::MethodOverride, [], {}, nil]]}>
With this middleware I have a form
<%= form_for book, "/books/#{id}", method: :patch do %>
<input name="book[image]" type="hidden" value="<%= book.image_data %>" />
<input name="book[image] "type="file" />
<button class="btn btn-primary" type="submit">Submit</button>
<% end %>
Which generates a form:
<form action="/books/3" method="POST" accept-charset="utf-8">
<input type="hidden" name="_method" value="PATCH">
<input type="hidden" name="_csrf_token" value="56bff67b47fb16b8a2870a386ca06da59e02eb827e6860c17379efb501c7c643">
<input name="book[image]" type="hidden" value="">
<input name="book[image] " type="file">
<button class="btn btn-primary" type="submit">Submit</button>
</form>
The form helper inputs, csrf and _method are here, so I kinda have no idea where the problem could be, but the errors is:
Hanami::Router::NotAllowedError at /books/3
Only PATCH requests are allowed at /books/3
The route is obviously written as a PATCH, but browsers only understand GET and POST, I saw that Hanami uses the same approach as rails with the rack middleware so I added it but no success.
The form is in slice, but the slice does not have separate config. But is that even relevant? app.config
above shows that the middleware is used.
@timriley moved this from chat as discussed.
Relevant code: wip:form not working · krzykamil/libus@141a5b3 · GitHub I added the form and middleware here