用户帖子的Gravatar(RoR)

时间:2013-06-24 19:03:04

标签: ruby-on-rails ruby gravatar

非常简单的ruby on rails问题。我正在制作一个应用程序,其中有讨论,用户可以评论它们,我希望他们的gravatar出现在他们评论的一边。怎么会这样做呢?谢谢!

_discussion.html.erb

<% content_for :script do %>
    <%= javascript_include_tag 'hover_content' %>
<% end %>

<% @micropost = Micropost.new %>
<% @micropost.discussion_id = discussion.id %>

<li>
  <div class = "intro-bar"><span class = "intro"><%=discussion.intro %></span></div>
  <div class = "content-bar">
    <span class = "content"><%= discussion.content %></span>
  </div>
  <input type='button' id='hideshow' value='hide/show'>
    <div class = "buttons">
      <!--<div class = "vote-neg"><%= link_to "Break Up", signup_path,class: "btn btn-large btn-breakup" %></div>-->
      <!--<div class = "vote-plus"><%= link_to "Stay Together", signup_path,class: "btn btn-large btn-staytogether" %></div>-->
    </div>

</li>

<span class = "timestamp">
    Posted <%= time_ago_in_words(discussion.created_at) %> ago.
  </span>

            <% if signed_in? %>
                <div class = "row">
                  <aside class = "span4">
                    <section>
                      <%= form_for(@micropost) do |f| %>
                          <%= render 'shared/error_messages', object: f.object %>
                          <div class="field">
                            <%= f.text_area :content, placeholder: "Post a comment" %>
                          </div>
                          <%= f.hidden_field :discussion_id%>

                          <%= f.submit "Break Up", class: "btn btn-large btn-breakup",:name => "break_up" %>
                          <%= f.submit "Stay Together", class: "btn btn-large btn-staytogether", :name => "stay_together" %>
                              <% end %>
                              </section>
                              </aside>
                              </div>
                          <% end %>

<div class = "comments">
  <% discussion.microposts.each do |micropost| %>
      <li>
        <div class = "comment-pic"></div>
        <div class = "post-comment"><%= micropost.content%></div>
      </li>
  <% end %>
</div>

用户显示页面

<% provide(:title, @user.username) %>
<div class="row">
  <aside class="span4">
    <section>
      <h1>
        <%= gravatar_for @user %>
        <%= @user.username %>
      </h1>
    </section>
  </aside>
</div>
<div id = "user_content">
  <p>
    <%= @user.email %><br/>
    <%= @user.age %> years old <br/>
    <%= @user.sex %> <br/>
  </p>
</div>
</div>

1 个答案:

答案 0 :(得分:0)

  

观看此视频直播视频,了解其实施情况。

     

RailsCasts Gravatar Tutorial