Search code examples
ruby-on-railsslim-lang

syntax error, unexpected ',', expecting ')' in slim rails


I'm get this kind of error while assigning style attribute to my image_tag element in slim rails

It's rus fine without style attribute but while appending style attribute i'm getting this error.

project/app/views/layouts/show.slim:16: syntax error, unexpected ',', expecting ')' ...dium_id(sect.id)[index]].file), style:"height:100%; width:10... ... ^

 [email protected]_index(0) do |sect,index|
    .border id="section#{sect.id}" class="layout-section" name="#{sect.id}"  style="position:absolute; height:#{sect.height}px; top:#{sect.position.split(",")[0]}px; left:#{sect.position.split(",")[1]}px;  width:#{sect.width}px;" 
                              
       = image_tag(@allmedia[find_CorrespondingMedium_id(sect.id)[index]].file),style:"height:100%; width:100%"

  end 

Solution

  • style needs to be inside the parentheses for image_tag

    = image_tag(@allmedia[find_CorrespondingMedium_id(sect.id)[index]].file, style:"height:100%; width:100%")
    
    # or with no parentheses
    = image_tag @allmedia[find_CorrespondingMedium_id(sect.id)[index]].file, style:"height:100%; width:100%"