Pluralize issues.

26 views
Skip to first unread message

Christopher Bird

unread,
Jan 17, 2016, 4:52:33 PM1/17/16
to Ruby on Rails: Documentation
All, I have been going through the tutorial at here:


I ran into an issue with the code snippet below.

<%= form_for :article, url: articles_path do |f| %>
 
  <% if @article.errors.any? %>
    <div id="error_explanation">
      <h2>
        <%= pluralize(@article.errors.count, "error") %> prohibited
        this article from being saved:
      </h2>
      <ul>
        <% @article.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

However, when I replace it with the pluralize method invocation without () as seen below, it works just fine. Any ideas what I have been doing wrong? (apologies for the awful formatting. Copy/Paste wasn't friendly!)

<%= form_for :article, url: article_path(@article) method: :patch do |f| %>

<% if @article.errors.any? %>
<div id = "Error Explanation">
<h2> 
    <%= pluralize @article.errors.count,'error' %>
   prohibited
this article from being saved: </h2>
<ul>
<% @article.errors.full_messages.each do |msg| %>
<li>
<%= msg %>
</li>
<% end %>
</ul>
</div>
<%end%>

Thanks for reading and commenting

Chris

Xavier Noria

unread,
Jan 19, 2016, 1:43:09 AM1/19/16
to rubyonra...@googlegroups.com
Did you find the issue?

If not, could you please copy the code in gists? Which is the error mssage?


--
Sent from Gmail Mobile
Reply all
Reply to author
Forward
0 new messages