diff --git a/app/controllers/contributions_controller.rb b/app/controllers/contributions_controller.rb index c09b932..272ceb2 100644 --- a/app/controllers/contributions_controller.rb +++ b/app/controllers/contributions_controller.rb @@ -3,16 +3,22 @@ class ContributionsController < ApplicationController before_action :set_member, only: %i[ new create ] before_action :set_contribution, only: %i[ edit update delete destroy ] - # GET /members/new + # GET /contributions + def index + @contributions = Contribution.all.order(payment_on: 'DESC') + @contributions = @contributions.select {|c| c.payment_on.year == params[:year].to_i } if params[:year] + end + + # GET /contributions/new def new @contribution = Contribution.new end - # GET /members/1/edit + # GET /contributions/1/edit def edit end - # POST /members + # POST /contributions def create @contribution = @member.contributions.build(contribution_params) @@ -29,7 +35,7 @@ class ContributionsController < ApplicationController end end - # PATCH/PUT /members/1 + # PATCH/PUT /contributions/1 def update if @contribution.update(contribution_params) redirect_to @contribution.member, notice: "Contribution was successfully updated." @@ -38,11 +44,11 @@ class ContributionsController < ApplicationController end end # - # GET /members/1/delete + # GET /contributions/1/delete def delete end - # DELETE /members/1 + # DELETE /contributions/1 def destroy @member = @contribution.member @contribution.destroy diff --git a/app/views/contributions/index.html.erb b/app/views/contributions/index.html.erb new file mode 100644 index 0000000..5e6db90 --- /dev/null +++ b/app/views/contributions/index.html.erb @@ -0,0 +1,24 @@ +
<%= notice %>
+ +<%= t('contributions.attributes.payment_on') %> | +<%= t('members.attributes.display_name') %> | +<%= t('contributions.attributes.amount') %> | +<%= t('contributions.attributes.payment_method') %> | +<%= t('members.index.actions.title') %> | +
---|---|---|---|---|
<%= contribution.payment_on %> | +<%= contribution.member.number %>. <%= contribution.member.display_name %> | +<%= contribution.eurocents %> | +<%= contribution.payment_method %> | ++ <%= link_to t('members.index.actions.show'), contribution.member %> + | +