Passing variable to partial failure

In the view.html.erb:

<%= render @posts %>

In each _post.html.erb:

<%= render partial: 'shared/block', locals: { 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 %>

I get the error: undefined local variable or method 'blockedcallsign'. What’s wrong with the code?

Thank you very much for your help.

Sorry, I should have included what’s inside the block: it’s a glyphicon block sign.

I’ve researched the correct format for including a block (example here), and I think I have it correct below (it works when I use a string such as ‘baz’). But when I use blockedcallsign, it still gives the error undefined local variable or method `blockedcallsign’.

The full code is below:

<%= button_to blockrelationships_path(
params: {
blocker_callsign: @character.callsign,
blocked_callsign: blockedcallsign, #‘baz’
viewed_callsign: @view_character.callsign
},
remote: true
),
class: ‘btn btn-default btn-xs’ do %>

<% end %>

``

I am completely at a loss. Is it perhaps something to do with calling a partial inside a partial?

I have had that sort of issue occasionally caused by a non-printable
character which has somehow got inserted into the source, try
re-typing the line where the parameter is passed and where it used to
eliminate that possibility.

If not that does it help if you call it with a string, blockedcallsign: "text"

Also try using the variable in the partial just as a string rather
than inside the button_to function, to prove it is not to do with the
context where you are using it.

As a final test try changing the parameter name. Not sure why it
should help but if nothing else it might give you a clue

Colin

Thank you all very much. I’m afraid the problem was me, being a moron. There’s nothing wrong with the code. There was a second forgotten ‘render’ in view.html.erb causing the problem. Sorry. Thank you once again.