简体   繁体   中英

render partial in rails

In my application I have an button as below.

<button type="button" data-toggle="modal" data-target="#askNetworkFormModal" class="hidden-xs btn btn-primary mb-10" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
   <span class=""><b>
     Ask
   </b></span>
</button>

Here data-target is modal call askNetworkFormModal which is in _askthenetwork.html.erb

I rendered it within application.html.erb as below

<%= render partial: 'layouts/askthenetwork' %>

I just want to render this only for the page which include my button. How can I do this.

I had resolve this by changing code as below.

<% if controller_name =="home" && action_name == "feed"%>
    <%= render partial: 'layouts/askthenetwork' %>
<% end %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM