[英]how to get host url in rails application
i am using model reveal feature with ajax call.我正在使用带有 ajax 调用的模型显示功能。 one application has more than one domain i tried
request.host
but this doesn't worked as expected.一个应用程序有多个域,我试过
request.host
但这没有按预期工作。 how can i get host with url as shown below-我怎样才能获得带有 url 的主机,如下所示 -
<div class="full reveal" id="<%= site_model_id %>" data-reveal data-ajax-url="http://0.0.0.0:3000/project_sites/<%= project_site.id %>/attendances/">
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
what i tried as url我试过的网址
data-ajax-url="#{request.host}/project_sites/<%= project_site.id %>/attendances/"
but this opens only root_page not target page.但这只会打开 root_page 而不是目标页面。
posted solution that worked for me:发布的解决方案对我有用:
<% domain = request.base_url %>
<div class="full reveal" id="<%= site_modal_id%>" data-reveal data-ajax-url="<%= domain %>/project_sites/<%= project_site.id %>/attendances/">
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.