0
json을 html로 임베드해야하고 #322 RailsCasts에는 RABL ...렌더링 할 객체 (: template => "template.json.rabl")
을 사용하는 방법이 나와 있습니다. 여기app/views/places/show.html.erb
<div id="place" data-place="<%= render(template: "places/show.json.rabl") %>" >
내 rabl 템플릿
app/views/places/show.json.rabl
object @place
attributes :id, :name, :desc, :address
node(:type) { |place| place.type_place.name }
child :photos do
attributes :id, :desc
node(:url) { |photo| photo.image.url(:square) }
end
이며, 그것은 잘 작동하지만 같은 다른보기에서 rabl 템플릿을 렌더링 할 :
app/views/places/finder.html.erb
<%= @places.each do |place| %>
<div id="place-<%= place.id %>" data-place="<%= render(template: "places/show.json.rabl") %>" >
<% end %>
,
이 나에게 다음 메시지 오류
전무에 대한정의되지 않은 메서드`type_place '을 보여줍니다 : 내가 생각하는 메시지에서 NilClass
Extracted source (around line #1):
1: object @place
2: attributes :id, :name, :desc, :address
3:
4: node(:type) { |place| place.type_place.name }
를 오류가 나는 물체의 위치를 전달하고 있지 않다 무엇인가 템플릿에 ... 나는 많이 노력했지만 이걸 얻지 못했습니다. 대한
미리 감사하고, 미안 내 영어
감사를 호출해야합니다. – figuedmundo