Ruby on Rails: conditionally display a partial

前端 未结 3 686
一个人的身影
一个人的身影 2021-02-11 14:05

I\'m not sure if I\'m doing the best approach here, but I have a block of data that I want to show after a search is done and to not be there at all before. First of all, there

3条回答
  •  臣服心动
    2021-02-11 14:45

    Assuming I am following you right, you do this at the view level.

    <% if !@my_search_data.nil? %>
    <% render :partial => 'foo/bar' %>
    <% end %>
    

    Hope that helps. If not, maybe post an example of your code.

提交回复
热议问题