6
प्रतिपादन करते हुए टेम्पलेट त्रुटि लापता मैं अपने नियंत्रक में निम्न कोड है:आतंक विरोधी: JSON
def tljson (result = [])
@stat_id = params[:stat_id]
@rpm = FedoraRpm.find_by_name(@stat_id)
@rpm.ruby_gem.historical_gems.each { |h|
result << { :content => h.version, :start => h.build_date }
}
@rpm.bugs.each { |b|
result << { :content => b.name + "<br><a href='"+b.url+"'>View on BugZilla</a>", :start => b.bz_id }
}
@res = result.to_json
respond_to do |format|
format.json { render @res.to_json }
end
end
/tljson.json के लिए जा रहे JSON से प्रस्तुत होती है शीर्षक कहते हैं, 'खाका लापता है; अनुपलब्ध टेम्पलेट '। मैं क्या गलत कर रहा हूं?
आपको '# to_json' पर कॉल करने की आवश्यकता नहीं है। – Hauleth
मैंने ऐसा करने की कोशिश की, यह इस त्रुटि को लौटाता है: #tljson figures_controller.rb: 42: वाक्यविन्यास त्रुटि, अप्रत्याशित ':', उम्मीद कर रहे हैं '}' – 17andLearning
यह तय किया गया त्रुटि: format.json {rendering: json => @res} – 17andLearning