--- !ruby/hash:ActionController::Parameters
utf8: ✓
authenticity_token: nNWNdGOzKSu5gfDkB4x3AFIO1PQnIggn65uE//SGQNzK8Ub5AOtsShH3CLZd+oU7ic9WlA+F0RbsSVR6X1I78w==
callsign: bazzer
notice: !ruby/hash:ActionController::Parameters
latitude: '51.75253980933651'
longitude: '-1.39801025390625'
content: Hello everyone
commit: Drop
controller: notices
action: create
Completed 500 Internal Server Error in 31ms (ActiveRecord: 7.1ms)
NoMethodError (undefined method `[]' for nil:NilClass):
I have updated my code to use a form builder. It's all working great except for this one problem. The code is below. For some reason the fields_for is not working - as the params above shows there should be an active_comment_relationship parameter for notice but it isn't present. What's wrong with this code?:
<%= form_for(:notice, url: :notices, method: :post, html: { multipart: true, class: "comment_form" } ) do |f| %>
<%= hidden_field_tag :callsign, @character.callsign %>
<%= f.fields_for :active_comment_relationship do |ff| %>
<%= ff.label :commentee_id %>
<%= ff.hidden_field :commentee_id, value: notice.id %>
<% end %>
<%= f.hidden_field :latitude, value: notice.latitude, id: "comment_notice_latitude" %>
<%= f.hidden_field :longitude, value: notice.longitude, id: "comment_notice_longitude" %>
<%= f.text_area :content, rows: 1, id: "commentField-#{notice.id}", class: "comment_area" %>
<%= f.submit( "Post", class: 'btn btn-default btn-xs',
onclick: "return validateCommentForm('#commentField-#{notice.id}');" ) do %>
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
<% end %>
<%= f.file_field :picture, accept: 'image/jpeg,image/gif,image/png' %>
<% end %>
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/79128726-63a6-4032-887e-50cb61f41bcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment