2

I am using Padrino and facing the next issue. I would like to render jsons, the controller is the following and then the error I always get.

I call the end point with:

curl -i -H "Accept: application/json" http://localhost:3000/mymodels
get :index, provides: [:html, :json] do
  @models = MyModel.all
  case content_type # is json!
  when :html then
    render "index", collection: @models
  when :json then
    # render @models.to_json, layout: false # does not work either
    render @models
  end
end

The error msg is: Padrino::Rendering::TemplateNotFound The above code based on this SO answer

Do you have any idea how I can make it render pure json and avoid tempate rendering in case of json?

Mark
  • 5,994
  • 5
  • 42
  • 55

0 Answers0