Ruby on rails 在if语句中使用当前路径/URL在rails中呈现表单
我需要在我的应用程序中创造销售机会。这些属于用户和公司。我已经对其进行了很好的配置,允许我从用户页面或公司页面创建新的销售机会,但目前新的销售机会页面使用相同的表单,无论我使用哪种路径访问该页面。见下文:Ruby on rails 在if语句中使用当前路径/URL在rails中呈现表单,ruby-on-rails,url,if-statement,path,routing,Ruby On Rails,Url,If Statement,Path,Routing,我需要在我的应用程序中创造销售机会。这些属于用户和公司。我已经对其进行了很好的配置,允许我从用户页面或公司页面创建新的销售机会,但目前新的销售机会页面使用相同的表单,无论我使用哪种路径访问该页面。见下文: <div class="container"> <div class="row"> <div class="span6 offset3"> <%= f.label :opportunity_name %><br>
<div class="container">
<div class="row">
<div class="span6 offset3">
<%= f.label :opportunity_name %><br>
<%= f.text_field :opportunity_name %>
<%= f.label :close_date %><br>
<div class='input-group date' id='datetimepicker' data-date-format="YY.MM.DD">
<%= f.text_field :close_date, class: "form-control", data: { date_format: 'YYYY/MM/DD' } %>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<%= f.label :pipeline_status %><br>
<%= f.select(:pipeline_status, options_for_select(@pipeline_statuses.collect { |r| [r[0].humanize, r[0]] }, selected: @sales_opportunity.pipeline_status), {}) %>
<%= f.label :sale_value %><br>
<%= f.number_field :sale_value, :step => 'any' %>
<%= f.hidden_field :user_id %>
<%= f.label :company_id %><br>
<%= f.collection_select :company_id, @user.organization.companies(:company_name), :id, :company_name %>
<%= f.submit "Save", class: "btn btn-large btn-primary" %>
<% end %>
</div>
</div>
并将其与if语句耦合:
<% if is_path?(new_company_sales_opportunity_path) %>
<div> Something other than the standard </div>
标准之外的东西
但这不起作用。有人能帮我找到正确的地址吗?你可以拨打
request.referer
查找引用url。你如何使用它?我只是尝试了一些或其他的方法,但它不起作用——忘了我的愚蠢吧,我在用'
<% if is_path?(new_company_sales_opportunity_path) %>
<div> Something other than the standard </div>