Skip to content

Instantly share code, notes, and snippets.

@ptagell
Created May 26, 2012 23:52
Show Gist options
  • Save ptagell/2795655 to your computer and use it in GitHub Desktop.
Save ptagell/2795655 to your computer and use it in GitHub Desktop.
List of goals
<% @goals.each do |goal| %>
<% if goal.committments.count == 1 && goal.committments.first.private_goal == true %>
<% else %>
<li>
<% if goal.committments.count > 1 %>
<p><small><%= goal.committments.count %> people want to</small></p>
<% else %>
<p><small><%= goal.committments.count %> person wants to</small></p>
<% end %>
<blockquote>
<p><%= goal.description %></p>
<br>
<small>
<% if user_signed_in? %>
<% goal.users.each do | user | %>
<% if current_user == user %>
You have this as a goal. Have you accomplished it yet?
<% else %>
<% end %>
<% end %>
<% end %>
<%= link_to "I also want to do this", new_committment_path(:goal_id => goal.id)%>
</small>
</blockquote>
</li>
<% end %>
<% end %>
@mattallen
Copy link

  <% @goals.sort{|x,y| y.commitments.count <=> x.commitments.count}.each  do |goal| %>
    <% next if goal.committments.count == 1 && goal.committments.first.private_goal == true %>
      <li>
        <% if goal.committments.count > 1 %>
          <p><small><%= goal.committments.count %> people want to</small></p>
        <% else %>
          <p><small><%= goal.committments.count %> person wants to</small></p>
        <% end %>
        <blockquote>
          <p><%= goal.description %></p>
          <br>
          <small>
          <% if user_signed_in? %>
            <% goal.users.each do | user | %>
              <% if current_user == user %>
                You have this as a goal. Have you accomplished it yet?
              <% else %>
              <% end %>
            <% end %>
          <% end %>


          <%= link_to "I also want to do this", new_committment_path(:goal_id => goal.id)%>  

          </small>
        </blockquote>
      </li>
  <% end %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment