Skip to content

Commit

Permalink
Add method to follows helper to get followable partial name and argum…
Browse files Browse the repository at this point in the history
…ents automatically.
  • Loading branch information
Senen committed Jul 18, 2017
1 parent 16987e7 commit 57c8887
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/helpers/follows_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def entity_icon(entity)
}.invert[entity]
end

def entity_partial(class_name)
class_name.parameterize.gsub('-','_')
end

private

def followed?(followable)
Expand Down
7 changes: 2 additions & 5 deletions app/views/users/_following.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
<table>
<tbody>
<% @follows.where(followable_type: followable_type).each do |follow| %>
<% if followable_type == "Proposal" %>
<%= render "proposal", proposal: follow.followable %>
<% elsif followable_type == "Budget::Investment" %>
<%= render "budget_investment", budget_investment: follow.followable %>
<% end %>
<%= render entity_partial(followable_type),
entity_partial(followable_type).to_sym => follow.followable %>
<% end %>
</tbody>
</table>
Expand Down
8 changes: 6 additions & 2 deletions app/views/users/_proposal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

<% if proposal.retired? %>

<td class="text-center">
<span class="label alert"><%= t('users.proposals.retired') %></span>
</td>

<% elsif author?(proposal) %>

<td class="text-center">
<%= link_to t("users.proposals.send_notification"),
new_proposal_notification_path(proposal_id: proposal.id),
class: 'button hollow' %>
</td>

<% elsif author?(proposal) %>

<td class="text-center">
<% if proposal.retired? %>
<span class="label alert"><%= t('users.proposals.retired') %></span>
Expand Down

0 comments on commit 57c8887

Please sign in to comment.