In the view.html.erb:
<%= render @posts %>
In each _post.html.erb:
<%= render 'shared/block', blockedcallsign: post.callsign %>
In each _block.html.erb:
<%= button_to blockrelationships_path, class: 'btn btn-default btn-xs',
params: {
blocker_callsign: @callsign,
blocked_callsign: @blockedcallsign
},
remote: true do %>
<% end %>
Looking at the server logs, the blocked_callsign parameter is blank. I'm not passing the variable to the partial correctly. What's wrong with the code?
EDIT
With blockedcallsign instead of @blockedcallsign in _block.html.erb:
<%= button_to blockrelationships_path, class: 'btn btn-default btn-xs',
params: {
blocker_callsign: @callsign,
blocked_callsign: blockedcallsign
},
remote: true do %>
<% end %>
and the following in _post.html.erb:
<%= render 'shared/block', locals: { blockedcallsign: post.callsign } %>
I get the error: undefined local variable or method 'blockedcallsign'.
Aucun commentaire:
Enregistrer un commentaire