All threads / ActionCable Part 3: can't write unknown attribute `user_id`, what am I missing?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

ActionCable Part 3: can't write unknown attribute `user_id`, what am I missing?

Rob Sturcke asked in General

Having some trouble figuring out what I'm missing with submitting a message in the chatroom, I get the error for my messages_controller.rb saying that can't write unknown attribute `user_id. However checking the source files I saw that my messages_controller.rb was the exact same as the example under my create saying message.user = current_user is incorrect:

Error encountered at about 13min into tutorial.

  def create
    message = @chatroom.messages.new(message_params)
    message.user = current_user
    message.save
    redirect_to @chatroom
  end

GoRails Screencast code from part 3:
https://github.com/gorails-screencasts/chatrooms/blob/0a3d687b759d51fd84f5f57158773f4418f6410f/app/controllers/messages_controller.rb

My Code:
https://github.com/robSturcke/halibut/blob/master/app/controllers/messages_controller.rb

Running ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin16], Rails 5.0.0.1

Thanks for your help,

-RS

Never mind! Missed adding user:reference when scrubbing back in the video!

I read this earlier and wasn't quite sure what it was, but that would explain it! :) Happy to help if you have any other questions.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 35,699+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.