adds helper to fix links to commentable

This commit is contained in:
Juanjo Bazán
2017-01-10 13:54:50 +01:00
parent f102f9f753
commit ad435040bd
2 changed files with 9 additions and 1 deletions

View File

@@ -20,6 +20,14 @@ module CommentsHelper
end
end
def commentable_path(comment)
if comment.commentable_type == "Budget::Investment"
budget_investment_path(comment.commentable.budget_id, comment.commentable)
else
comment.commentable
end
end
def user_level_class(comment)
if comment.as_administrator?
"is-admin"

View File

@@ -1,6 +1,6 @@
<div class="row">
<div class="small-12 column margin-top">
<%= link_to @comment.commentable, class: "back" do %>
<%= link_to commentable_path(@comment), class: "back" do %>
<span class="icon-angle-left"></span>
<%= t("comments.show.return_to_commentable") + @comment.commentable.title %>
<% end %>