Skip to content

Commit

Permalink
Add expenses index
Browse files Browse the repository at this point in the history
  • Loading branch information
williamscch committed Nov 16, 2022
1 parent 2fe43f6 commit a763c40
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/controllers/expenses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ExpensesController < ApplicationController

# GET /expenses or /expenses.json
def index
@expenses = @group.expenses
@expenses = @user.expenses.all.order(created_at: :desc)
end

# GET /expenses/1 or /expenses/1.json
Expand Down
2 changes: 1 addition & 1 deletion app/views/expenses/_expense.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
<%= expense.group_ids %>
</p>

<%= link_to "Edit", edit_group_expense_path(@category, expense) %>
<%= link_to "Edit", edit_group_expense_path(@group, expense) %>

</div>
3 changes: 1 addition & 2 deletions app/views/expenses/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
<br>

<div>
<%= link_to "Show this expense", @expense %> |
<%= link_to "Back to expenses", expenses_path %>
<%= link_to "Back to Group", group_path(@group) %>
</div>
4 changes: 2 additions & 2 deletions app/views/expenses/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<% @expenses.each do |expense| %>
<%= render expense %>
<p>
<%= link_to "Show this expense", expense %>
<%= link_to "Show this expense", group_expense_path(@group, expense) %>
</p>
<% end %>
</div>

<%= link_to "New expense", new_expense_path %>
<%= link_to "New expense", new_group_expense_path %>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
end

resources :groups do
resources :expenses, only: %i[new create edit update]
resources :expenses
end
resources :users, only: %i[edit update]
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
Expand Down

0 comments on commit a763c40

Please sign in to comment.