I have the following code in my controller:
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
Going to /tljson.json renders the JSON but the heading says 'Template is Missing; missing template'. What am I doing wrong?
I believe you need to specify that you want to render :json
in your respond_to
block
respond_to do |format|
format.json { render json: @res }
end
Otherwise it will look for a tljson.json.erb
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With