Rails view error (on nitrous io IDE) syntax error, unexpected keyword_ensure, expecting end-of-input

33 Views Asked by At

i'm having problems with my code ,i get this message above.here is my code .i'm new to ruby

app/views/articles/edit.html.erb

<h>Edit existing article</h>
<%[email protected] %>
<h2>The following errors prevented the article from getting created</h 2>
<ul>
<%@article.errors.full_messages.each do  |ms g| %>
<li><% ms g %></l i>
<% end %>
</ul>
<% end %>
<%= form_for @article do |f| %>
 <p>
   <%= f.label :title %><b r/>
   <%= f.text_field :title %>
</p>
<p>
  <%= f.label :description %><br/>
  <%= f.text_area :description %>
</p>
<p>
  <%=f.submit %>
<% end %>
2

There are 2 best solutions below

0
Anthony E On

You have a bunch of spaces where you probably didn't intend them (including the text in your post above).

I think you meant for ms g to be msg on this section:

<%@article.errors.full_messages.each do  |msg| %>  # `ms g` => `msg`
  <li><% msg %></li> # `ms g` => `msg`

Also remove the space in </l i> and <b r/>

2
trh On

You seem to have a cut and paste, or perhaps an editor issue - there are several lines with breaks between words.

And you have an extra <% end %> tag that doesn't seem to line up to anything

Try this instead

<h>Edit existing article</h>
<%[email protected] %>
<h2>The following errors prevented the article from getting created</h2>
<ul>
  <%@article.errors.full_messages.each do  |msg| %>
    <li><%= msg %></li>
  <% end %>
</ul>
<%= form_for @article do |f| %>
  <p>
  <%= f.label :title %><br/>
  <%= f.text_field :title %>
  </p>
  <p>
  <%= f.label :description %><br/>
  <%= f.text_area :description %>
  </p>
  <p>
  <%=f.submit %>
<% end %>