Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

ActionController::UnknownFormat in MessagesController#create

General • Asked by Rob Sturcke

Ran into this error in part 4 of the ActionCable group chat. What exactly am I missing? Schema looks fine same with MessagesController.

ActionController::UnknownFormat in MessagesController#create
MessagesController#create is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: []
raise ActionController::UnknownFormat, message

What am I missing?

Hey Rob,

I can't remember exactly, but I know a couple people also had trouble with that one. I believe this was where we setup the form to submit as AJAX and hadn't transitioned it over to sending via the websocket just yet.

Your form is submitting, but it's not sending as a JS request, so your create action crashes looking for an HTML response. What you need is to add remote: true to the form so that will render and execute the create.js.erb file we created.

Basically just change this line:

to the following:

<%= form_for [@chatroom,], remote: true do |f| %>

That should do the trick! Your form needs to submit via AJAX request so that the browser doesn't reload the page each time you send a message. That'd be a really poor experience.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 29,763+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.