Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown format in rails 4

I'm using rails 4. But I am getting unknown format error. Do you guys have any help for me. Here is my controller:

class EntriesController < ApplicationController
  respond_to :json

  def index
    respond_with Entry.all
  end
end

enter image description here

like image 215
user3366155 Avatar asked May 11 '14 08:05

user3366155


2 Answers

Add this to your routes config

resources :entries, defaults: { format: 'json' }

like image 90
John Nguyen Avatar answered Oct 28 '22 16:10

John Nguyen


def index
  respond_to do |format|

    @entry = Entry.all

    format.html 
    format.json { render json: @entry }

  end
end

hope it will help you

like image 9
matanco Avatar answered Oct 28 '22 16:10

matanco