I have two actions in my controller :
def find
@item = Item.find(params[:id])
render 'result', :id => @item.id
end
def result
@item = Item.find(params[:id])
respond_to do |format|
format.js
end
end
The issue in that I call first the find
action, then it calls the result
action but in the html format. So the 'format.js` is never triggered.
How can render, at the end of the find
action, the result
action in the js format ?
Thanks a lot !
在find方法中尝试这个。
render 'result', :id => @item.id, :format => :js
Try this
<%= render 'components/activity-slider', populer_packages: @populer_packages %>
components/activity-slider
<div class="slider sliderSecondary activitiesSlider">
<% populer_packages.each do |package| %>
<a href="#" class="sliderGrid ">
<div class="sliderCont">
<div class="sliderGradient"></div>
<div class="sliderThumb">
<div class="sliderImgWrap">
<%= image_tag "#{package.image}", class: "img-fluid sliderImg" %>
<div class="overlayCaptionCont">
<div class="overlayCaptionWrap">
<div class="overlayCaption">
<ul class="list-unstyled captionList">
<li>test</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</a>
<% end %>
</div>
render
方法只渲染视图,不调用另一个动作
The bigger issue here is that you are trying to call another action, which breaks MVC pattern. Even though actions are defined as methods, think of them as something else, that cannot call other actions.
Also, please reply with code from your views that are calling/trigger these actions.
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.