<% @labels.each do |label| %>
<input type="text" name="<%=label.name%>" value="<%=@car.(label.related_to) %>" class="big-font" style="width: <%=label.width%>px; top: <%=label.y_coor%>px; left: <%=label.x_coor%>px;" />
<% end %>
Hello guys, I’m new to rails so this should be a fairly easy question to answer.
The issue is here: <%=@car.(label.related_to) %>.
label.related_to holds the string “make”. I’m trying to get it to do this pretty much: @car.make
Any idea guys?
Thanks,
Alain
Use
sendto send a message to an object:If there is any chance of
label.related_tonot being a valid method for the object, you’ll probably want to be prepared to catch theNoMethodError