Closed keferboeck closed 8 years ago
I answered your StackOverflow question, and I'll just copy it in here as well.
You should swap the last match '*path'
line with the post '/tinymce_assets/'
line. That will probably take care of it, or at least get you a bit further.
Routes in Rails match from the top, so match '*path'
matches a POST to /tinymce_assets/
, sees it doesn't have a locale, and does the redirect, via GET. Your application never reaches the line for post '/tinymce_assets'
.
Cleaning up…
It was nginx rewriting URLs by adding slashes at the end that caused the problems. Better explanation available on StackOverflow.
It works just fine in Development (funny enough it used to work also in Production). The problem is that on production it issues the wrong GET request:
ActionController::RoutingError (No route matches [GET] "/at/tinymce_assets"):
Two issues here: Firstly - it puts a locale in front, secondly it uses a GET request.On development however it works fine:
Started POST "/tinymce_assets" for 127.0.0.1 at 2015-09-27 02:33:10 +0200 Processing by TinymceAssetsController#create as HTML
My routes.rb looks like this:Rails.application.routes.draw do root to: 'static_pages#redirect' localized do match '', to: 'static_pages#welcome', :as => 'welcome', via: 'get' ... lots of other stuff ... end match '*path', to: redirect("/#{I18n.locale}/%{path}"), constraints: lambda { |req| !req.path.starts_with? "/#{I18n.default_locale}/" }, via: 'get' post '/tinymce_assets/' => 'tinymce_assets#create', :trailing_slash => false end
I am adding here the :trailing_slash => false - as it is set to true in environment.rbQuestion:
Why does the production to site decide to fire a GET request + adding the locale, but the development does everything its supposed to do? Where can I set this behaviour, or is this a but in imageupload ?
http://stackoverflow.com/questions/32803453/rails-tinymce-imageupload-is-requesting-get-instead-of-post-as-in-development