From 7de19acaa0896936c24556c8edb9a328a9f47ab2 Mon Sep 17 00:00:00 2001 From: Enrico Stano Date: Wed, 22 Aug 2018 14:11:13 +0200 Subject: [PATCH] Remove posts helper --- app/helpers/posts_helper.rb | 13 ------------- app/views/shared/_post.html.erb | 8 +++++--- app/views/shared/_posts.html.erb | 8 ++++++-- app/views/tags/_grouped_index.html.erb | 2 +- 4 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 app/helpers/posts_helper.rb diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb deleted file mode 100644 index 1737bf674..000000000 --- a/app/helpers/posts_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -module PostsHelper - # Returns the right path to index list depending on type of post - def get_index_path(post, hparams) - klass = post.class - - case - when klass == String - post.eql?("offers") ? offers_path(hparams) : inquiries_path(hparams) - else - post.type.eql?("Offer") ? offers_path(hparams) : inquiries_path(hparams) - end - end -end diff --git a/app/views/shared/_post.html.erb b/app/views/shared/_post.html.erb index 370e03362..4dc0a4c59 100644 --- a/app/views/shared/_post.html.erb +++ b/app/views/shared/_post.html.erb @@ -12,8 +12,8 @@
<%= l post.updated_at.to_date, format: :long %>

- <%= link_to get_index_path(post, cat: post.category) do %> - <%= glyph :folder_open %> + <%= link_to [post.class, cat: post.category] do %> + <%= glyph(:folder_open) %> <%= post.category %> <% end %>

@@ -21,7 +21,9 @@ <% post.tags.each do |tag| %> <%= glyph(:tag) %> - <%= link_to tag, get_index_path(post, tag: tag) %> + <%= link_to [post.class, tag: tag] do %> + <%= tag %> + <% end %> <% end %> <% end %> diff --git a/app/views/shared/_posts.html.erb b/app/views/shared/_posts.html.erb index 44ad8fd04..1e2dc89e6 100644 --- a/app/views/shared/_posts.html.erb +++ b/app/views/shared/_posts.html.erb @@ -11,12 +11,16 @@ <% if post.category %> <%= glyph :folder_open %> - <%= link_to post.category, get_index_path(post, cat: post.category) %> + <%= link_to [post.class, cat: post.category] do %> + <%= post.category %> + <% end %> <% end %> <% (post.tags || []).each do |tag| %> <%= glyph :tag %> - <%= link_to tag, get_index_path(post,tag: tag) %> + <%= link_to [post.class, tag: tag] do %> + <%= tag %> + <% end %> <% end %>

diff --git a/app/views/tags/_grouped_index.html.erb b/app/views/tags/_grouped_index.html.erb index 3a0704d8f..befe8c6c2 100644 --- a/app/views/tags/_grouped_index.html.erb +++ b/app/views/tags/_grouped_index.html.erb @@ -11,7 +11,7 @@
<%= count %>
- <%= link_to get_index_path(post_type.pluralize, tag: tag) do %> + <%= link_to [post_type.pluralize, tag: tag] do %> <%= glyph count == 1 ? :tag : :tags %> <%= tag %> <% end %>