-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use current_tenant to get scoped fund and use for urls
- Loading branch information
Cameron Hicks
committed
Mar 16, 2023
1 parent
ea98081
commit 4e5370d
Showing
11 changed files
with
136 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
class FundsController < ApplicationController | ||
before_action :confirm_admin_user | ||
before_action :confirm_data_access, only: [:edit, :update] | ||
before_action :set_fund, only: %i[show edit update destroy] | ||
rescue_from ActiveRecord::RecordNotFound, with: -> { head :bad_request } | ||
|
||
# GET /funds | ||
def index | ||
@funds = Fund.all.sort_by { |f| [f.name] } | ||
end | ||
# def index | ||
# @funds = Fund.all.sort_by { |f| [f.name] } | ||
# end | ||
|
||
# GET /funds/1 | ||
# GET /fund | ||
def show | ||
@fund | ||
set_fund | ||
end | ||
|
||
# GET /funds/edit | ||
def edit; end | ||
# def edit | ||
# set_fund | ||
# end | ||
|
||
# PATCH/PUT /funds/1 | ||
# PATCH /fund | ||
def update | ||
set_fund | ||
if @fund.update(fund_params) | ||
redirect_to @fund, notice: 'Fund was successfully updated.' | ||
else | ||
render :edit, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def destroy; end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_fund | ||
@fund = Fund.find(params[:id]) | ||
@fund = current_tenant | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def fund_params | ||
params.fetch(:fund, {}) | ||
params.require(:fund) | ||
.permit(:full_name, :site_domain, :phone) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
<p style="text-align:right;"><strong><%= link_to "Back", fund_url(current_tenant) %></strong></p> | ||
<h1> | ||
<%= t 'funds.edit.title' %> | ||
</h1> | ||
|
||
<%= render 'funds/fund_form', | ||
fund: @fund, | ||
fund: current_tenant, | ||
label: t('funds.form.save_changes') %> | ||
|
||
<div> | ||
<%= link_to "Show this fund", @fund %> | | ||
<%= link_to "Back to funds", funds_path %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<h1><%= current_tenant.name %></h1> | ||
|
||
<div class="fund-list"> | ||
<table class="table border-side table-hover top-spacer" id="funds_table"> | ||
<thead> | ||
<tr class="funds-table-header"> | ||
<th><%= t 'activerecord.attributes.fund.subdomain' %></th> | ||
<th><%= t 'activerecord.attributes.fund.domain' %></th> | ||
<th><%= t 'activerecord.attributes.fund.full_name' %></th> | ||
<th><%= t 'activerecord.attributes.fund.site_domain' %></th> | ||
<th><%= t 'activerecord.attributes.fund.phone' %></th> | ||
<th><!-- spacer --></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<tr class="funds-table-row"> | ||
<td><%= current_tenant.subdomain %></td> | ||
<td><%= current_tenant.domain %></td> | ||
<td><%= current_tenant.full_name %></td> | ||
<td><%= current_tenant.site_domain %></td> | ||
<td><%= current_tenant.phone %></td> | ||
<td><%= link_to "Edit", edit_fund_path(current_tenant) %></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.