I am having an issue that I can't nail down and the other related questions don't seem to ever encounter this issue. I have a Message model and I am trying to add a Message (I am writing this to test something with Faye). I encountered an issue with Rails 4 and strong parameters. I followed the steps in the documentation to fix it but I am getting this error:
NoMethodError: undefined method `message' for #Message:0x007fc081202968>
Here is my controller and the section of the documentation where it directs you to do strong parameters this way (http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters):
class MessagesController < ApplicationController
def index
@messages = Message.all
end
def create
@message = Message.create!(message_params)
end
private
def message_params
params.require(:message).permit(:content)
end
end
Here is my model, very bare bones at this point:
class Message < ActiveRecord::Base
validates_presence_of :message
end
This is my form that I am submitting it with:
<%= form_for Message.new, remote: true do |f| %>
<%= f.text_field :content %>
<%= f.submit "Post" %>
<% end %>
I cannot figure out where the method "message" is being called on the message model. It says it is in the create action, I go there and it links to the strong parameters private method. I don't see how that is call "message" as the method anywhere. I am at a loss. I did binding.pry and walked through it step by step but I can't find where it is calling it there and it still fails when I step through with binding.pry.
Any help would be appreciated. I am guessing it is something obvious that I am overlooking at this point.
EDIT: add link to docs and change language surrounding my use of binding.pry
Found the problem, and it was obvious and ridiculous. In the validation I put the :content field is :message.