私のindex.html.erbには、Ajax経由で送信するフォームがあります(私は思う):remote => true
<%= form_tag locations_path, :method => :get, :remote=>true do %>
<p>
<%= text_field_tag :location, params[:location] %>
<%= submit_tag "Search Near", :name => nil %>
</p>
<% end %>
index アクションでは、json 経由で @locations を返すように設定するように配置されています
def index
if params[:location].present?
@locations = Location.near(params[:location], 5 , :order => :distance)
else
@locations = Location.all
end
respond_to do |format|
format.html # new.html.erb
format.json { render json: @locations }
end
end
今のところ、@locations を返すだけです (願っています)。index.html.erb のこの div で @locations の結果を取得するにはどうすればよいですか?
<div class="places"> </div>