7

I am using through AngularJS to send some json, in the controller I have

respond_to :json

def create
    respond_with Task.create(description: params[:description])
end

the tasks is stored on the database, but then I get this message in my log

ActionController::UnknownFormat - ActionController::UnknownFormat:
  (gem) actionpack-4.0.0/lib/action_controller/metal/mime_responds.rb:372:in `retrieve_collector_from_mimes'
  (gem) actionpack-4.0.0/lib/action_controller/metal/mime_responds.rb:327:in `respond_with'

...

I tried to add in my route resources :tasks, :defaults => {:format => "js"}. How can I handle this problem ?

Stewie
  • 60,366
  • 20
  • 146
  • 113
user1611830
  • 4,749
  • 10
  • 52
  • 89

1 Answers1

9

You want your default format to be "json", not "js".

Rails has a list of formats that it is expecting (based on defaults plus you or gems can add additional known response types.) Js is not one of the defaults

Chris
  • 11,819
  • 19
  • 91
  • 145