Method 1 (as suggested by the dangerous):
config / application.rb:
config.action_dispatch.default_headers.merge!({ 'Access-Control-Allow-Origin' => '*', 'Access-Control-Request-Method' => '*' })
Method 2 (which he used in himself): In the layouts of the necessary pages, added a render of the partial modal window. Js code from js.erb rendered the code for the relevant pages in js. Made the second route to the desired action, it turned out something like this:
constraints(Subdomain) do post 'action_second/create', to: 'controller#create' end constraints :subdomain => '' do post 'action_first/create', to: 'controller#create' end
PS
class Subdomain def self.matches?(request) request.subdomain.present? end end