0
我想讓我的部分顯示搜索結果在rails視圖中。當我檢查我的控制檯>網絡>預覽,我看到我的部分呈現與我需要的數據,但它不顯示在我的看法。Rails部分呈現控制檯網絡響應,但不在視圖中
這裏是我的應用程序/控制器/ searchs_controller.rb
def nearby_guides
@address = params[:address]
initial_array = @address.split(',')
city = initial_array[0]
state = initial_array[1].split(' ')
final_state = state[0]
country = initial_array[2]
@result = User.where("city = ?", city)
respond_to do |format|
format.html {render :partial => '/searchs/result', object: @result}
end
end
這裏是我的意見/ searchs/_result.html.erb
<h1>HELLO WORLD</h1>
<% if @result %>
<% @result.each do |r| %>
<p><%= r.firstname %></p>
<% end %>
<% end %>
在我的意見/ searchs/new.html.erb
然後
<%= render 'result' %>
這是我的控制檯>網絡>預覽我看到響應
HELLO WORLD
Kevin
這正是我期望的響應,但它又不會在視圖中顯示。我看過堆棧溢出沒有運氣。非常感謝任何和所有幫助!