ruby on rails - Strange:two same code ,one goes well ,but the other showe error, i've checked for many times -
two same coding,but 1 goes well,the other 1 doesn't work
error message
/users/kevin/rails101/app/views/groups/index.html.erb:21: syntax error, unexpected keyword_end, expecting ')' '.freeze; end ^ /users/kevin/rails101/app/views/groups/index.html.erb:26: syntax error, unexpected keyword_ensure, expecting ')' /users/kevin/rails101/app/views/groups/index.html.erb:28: syntax error, unexpected keyword_end, expecting ')'
here 1 showes error
<div class="col-md-12"> <div class="group"> <%= link_to("new group", new_group_path, class: "btn btn-primary pull-right") %> </div> <table class="table table-hover"> <thead> <tr> <td>#</td> <td>title</td> <td>description</td> </tr> </thead> <tbody> <% @groups.each |group| %> <tr> <td>#</td> <td><%= link_to(group.title, group_path(group)) %></td> <td><%= group.description %> </td> <td> <%= link_to("edit", edit_group_path(group), class: "btn btn-sm btn-default"%> <%= link_to("delete", group_path(group), class: "btn btn-sm btn-default", method: :delete, data: {confirm: "are sure?"} )%> </td> </tr> <% end %> </tbody> </table> </div>
the other 1 goes well:
<div class="col-md-12"> <div class="group"> <%= link_to("new group", new_group_path, class: "btn btn-primary pull-right") %> </div> <table class="table table-hover"> <thead> <tr> <td>#</td> <td>title</td> <td>description</td> </tr> </thead> <tbody> <% @groups.each |group| %> <tr> <td>#</td> <td><%= link_to(group.title, group_path(group)) %></td> <td><%= group.description %></td> <td> <%= link_to("edit", edit_group_path(group), class: "btn btn-sm btn-default")%> <%= link_to("delete", group_path(group), class: "btn btn-sm btn-default", method: :delete, data: { confirm: "are sure?" } )%> </td> </tr> <% end %> </tbody> </table> </div>
you're missing parenthesis here:
<%= link_to("edit", edit_group_path(group), class: "btn btn-sm btn-default"%>
it should
<%= link_to("edit", edit_group_path(group), class: "btn btn-sm btn-default")%>
Comments
Post a Comment