简体   繁体   中英

failing to render application.html.erb

I am failing to render my application.html.erb template i am getting the following error ActionView::SyntaxErrorInTemplate in ApplicationController#home

app/views/layouts/application.HTML.erb:10: syntax error, unexpected ':', expecting ')'
app/views/layouts/application.HTML.erb:11: syntax error, unexpected ':', expecting ')'

This is what the code looks like this application.html.erb

<!DOCTYPE html>
<html>

<head>
  <title>Appz</title>
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

      <%= stylesheet_link_tag "application" , "data-turbo-track" : "reload" %>
        <%= javascript_include_tag "application" , "data-turbo-track" : "reload" , defer: true %>
</head>

<body>
  <div class="container">
    <div class="row">
      <div class="col">
      </div>
    </div>
  </div>
  <%= yield %>
</body>

</html>

my code looks ok I have tried everything what could be the problem

You need to remove white space before:. Change the line and below line like this: <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>

Yes removing the white space works apparently I had a formatting extension enabled in vs code and it was messing up my code it was auto indenting unnecessarily and messing up the code I only became aware when I tried to correct the code by removing the white space and each time I saved it auto indented until I disabled the extension and it stopped I have since uninstalled the extension. So be careful what kind of extensions you install in your code editor you will get new and unfounded errors no one has seen before.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM