Question

<%= render 'shared/modal',
    id: 'assignToModal', 
    button: '<button onclick="groupAssignTo('<%= _id %>');">Assign</button>' %>

Consider the above code in a rails app view file(.html.erb). It will throw a,

ActionView::Template::Error (/home/think/../app/views/junks/_abc.html.erb:39: 
syntax error, unexpected tIDENTIFIER, expecting keyword_end

Its because in the button local of the render statement, the single quote starts before < and does not end after >, instead ends before <%=

How to approach this?

Was it helpful?

Solution

You are placing <%= %> tag inside another <%= %> tag

<%= render 'shared/modal',
    id: 'assignToModal', 
    button: '<button onclick="groupAssignTo(' + _id + ');">Assign</button>' %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top