From ccb36dc9b424fef8b9b5296eae0f773291f12e8d Mon Sep 17 00:00:00 2001 From: Juzer Shakir Date: Tue, 13 Aug 2024 19:28:02 +0530 Subject: [PATCH] Show only Open Bounties by default (#68) * show `'open'` bounties by default at root path * set filter to '`none`' to fetch all bounties * show custom msg if no open bounties are found --- app/controllers/bounties_controller.rb | 1 + app/views/bounties/index.html.erb | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/controllers/bounties_controller.rb b/app/controllers/bounties_controller.rb index 13abfef..39a4327 100644 --- a/app/controllers/bounties_controller.rb +++ b/app/controllers/bounties_controller.rb @@ -5,6 +5,7 @@ class BountiesController < ApplicationController # GET /bounties or /bounties.json def index + params[:filter] = "open" if params[:filter].nil? @bounties = Bounty.sorted @filter, @bounties = params[:filter], @bounties.filtered(params[:filter]) if Bounty::STATUSES.include?(params[:filter]) @pagy, @bounties = pagy(@bounties) diff --git a/app/views/bounties/index.html.erb b/app/views/bounties/index.html.erb index 0f90da4..abbce0a 100644 --- a/app/views/bounties/index.html.erb +++ b/app/views/bounties/index.html.erb @@ -5,15 +5,25 @@

<%= (@filter || "All").titleize %> Bounties

-
- <%= render @bounties %> -
+<% if @bounties.present? %> +
+ <%= render @bounties %> +
-<%== pagy_nav(@pagy).html_safe %> + <%== pagy_nav(@pagy).html_safe %> +<% else %> + <% if @filter == "open" %> +

+ There are no open bounties right now. +
+ Spread the word that we need people to post new Beginner Bounties! +

+ <% end %> +<% end %>