내 뷰에서 호출 할 때 왜 테이블을 생성하지 않습니까? fields_table (@user, [ "id", "username"])을 사용하면 tbody의 trs 또는 tds를 얻지는 못하지만 다른 모든 것은 얻고 있습니다.Ruby on Rails에서 테이블 생성
def fields_table(obj, fields)
return false if obj.nil?
content_tag(:table) do
thead = content_tag(:thead) do
content_tag(:tr) do
content_tag(:td, "Property") + content_tag(:td, "Value")
end
end
tbody = content_tag(:tbody) do
fields.each do |name|
content_tag(:tr) do
content_tag(:td, name) + content_tag(:td, obj.read_attribute(name))
end
end
end
thead + tbody
end
end
하지만에만 TBODY한다. 내가 디버깅하려하지만 어쩌면 왜 그런지 알아? – Dave
구글 "html_safe", 어딘가에는 신뢰할 수없는 문자열이 있으므로 더 이상 안전하게 표시 할 수 없습니다. 해당 메소드에 ".html_safe"를 추가하고 거기에서부터 수정하여 문제를 해결할 수 있습니다. –