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 ?
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
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