0

working on lesson 11 in the tutorial and i ran db:populate to show 50 microposts for the first 6 users

but when looking on browser page it says "Posted ago" on all microposts

in micropost.html.erb file:

<tr>
    <td class="micropost">
      <span class="content"><%= micropost.content %></span>
      <span class="timestamp">
        Posted <%= time_ago_in_words(micropost.created_at) %> ago.
      </span>
    </td>
</tr>

any ideas?

update 1:

trying to trial and error and when i change the ago. to agooooo. just to see if it changes on browser... it doesnt... i restarted autotest, spork and, rails s to see if it would show the Posted agoooooo. and nothing changes just holds "Posted ago."

update 2:

if you need to see my show.html.erb file

<table class="profile" summary="Profile information">
    <tr>
        <td class="main">
            <h1>
                <%= gravatar_for @user %>
                <%= @user.name %>
            </h1>
            <% if @user.microposts.any? %>
                <table class="microposts" summary="User microposts"> 
                    <%= render @microposts %>
                </table>
                <%= will_paginate @microposts %>
            <% end %>
        </td>
        <td class="sidebar round"> 
            <strong>Name</strong> <%= @user.name %><br />
            <strong>URL</strong> <%= link_to user_path(@user), @user %> <br />
            <strong>Microposts</strong> <%= @user.microposts.count %>
            </td>
    </tr>


</table>

Update 3:

adding the help. before may work but im confused why when i change Posted or ago to different words they dont change at all on the browser... whats the best way to send a full refresh so server sees these changes... tried restarting rails server, spork and autotest

Update 4:

I somehow have 2 _micropost.html.erb files in different locations.... solving problem now will post again in moment

Update 5:

I had a micropost folder with _micropost.html.erb file inside my users folder... which i had open

the correct micropost folder inside app => views => microposts => microposts.html.erb was missing a = in the <%=

I had been editing the wrong file the whole time i believe

As for adding a helper. -- it didnt work but it lead me to the problem -- so i consider that a solution in my book!

thank you very much ardavis!

4

1 回答 1

1
ruby-1.9.2-p180 :061 > helper.time_ago_in_words(u.created_at)
 => "11 days" 

Looks like you need to add 'helper' to the front.

Check out this page. It looks like he created his own custom method to make this better. Might help you.

于 2011-06-27T16:06:59.083 回答