6
Ho il seguente codice nel mio controller:RoR: Modello di errore mancante durante il rendering 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
Andare /tljson.json rende il JSON, ma il titolo dice 'Template è mancante; modello mancante '. Che cosa sto facendo di sbagliato?
Non è necessario chiamare '# to_json'. – Hauleth
Ho provato a farlo, restituisce questo errore: SyntaxError in #tljson stats_controller.rb: 42: errore di sintassi, imprevisto ':', in attesa di '}' – 17andLearning
risolto questo errore: format.json {render: json => @res} – 17andLearning