Looked at a number of resources and can't seem to figure this out.
I am working on a messaging system based on this code by BinaryMuse:
https://github.com/BinaryMuse/so_association_expirement/compare/53f2263...master
It doesn't have a respond feature, so I'm trying to build it.
I added the following code to the UserConversations controller:
def update
@user = User.find params[:user_id]
@conversation = UserConversation.find params[:id]
@conversation.user = current_user
@message = @conversation.messages.build
@message.conversation_id = @conversation
@message.save
redirect_to user_conversation_path(current_user, @conversation)
end
And the following to the UserConversations#show view:
<%= form_for(@conversation) do |f| %>
<%= f.fields_for :messages do |m| %>
<div>
<%= m.label :body %><br />
<%= m.text_area :body %>
</div>
<% end %>
<%= f.submit %>
With what I have, a new message with the correct conversation_id is created. However, it has no body or user_id attached to it.
Any ideas what I'm doing wrong?
Thanks in advance for your help!