In my RoR project I got html page, where I changing div's background image with javascript. Javascript function send me index, and I want to use this index for getting element of ruby array.
Look into my code
function drawNewProject (index){
console.log(<%= 'index' %>)
<% index = 'index' %>
<% @existProjects = Admin::Project.order('weight') %>
<% @existProject = @existProjects[index] %>
var image = document.getElementById('block_one')
image.style.backgroundImage="url('<%= @existProject.image(:large) %>')";
}
But this line
<% @existProject = @existProjects[index] %>
Gives me error
no implicit conversion of String into Integer
Do you know how to do it correct? Thnx.