Routing Error with Post/Put requests (Passenger Headers)

前端 未结 3 666
無奈伤痛
無奈伤痛 2021-01-06 00:27

I\'ve run into a weird problem and after a bunch of research can\'t get any closer. I\'ve got several forms that upload files via Carrierwave. When I upload the information,

3条回答
  •  情话喂你
    2021-01-06 01:22

    I think you may need to add

    :via => [:post]
    

    to your route specification. It seems odd that it'd work on development and not on production, but as I understand rails routing, the matcher that you've added is only going to respond to get.

    Try changing your match to

    match "add_file" => "programs#add_file", :via => [:post]
    

    Also, based on the answer just submitted by Andrew, you're probably better off using the member specifier to be explicit about the fact that the operation is happening on a particular Program with a particular id, and not the collection. It also should save some code in your add_file method which is probably working hard to get the id parameter from the url.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题