diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index fd36c16..d97ab50 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -47,10 +47,7 @@ def destroy
@group = current_user.groups.find(params[:id])
@group.destroy
- respond_to do |format|
- format.html { redirect_to groups_url, notice: 'group was successfully destroyed.' }
- format.json { head :no_content }
- end
+ redirect_back(fallback_location: root_path)
end
private
diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb
index 784a5ae..9dd56ec 100644
--- a/app/controllers/static_pages_controller.rb
+++ b/app/controllers/static_pages_controller.rb
@@ -3,4 +3,15 @@ class StaticPagesController < ApplicationController
def home
end
+
+ def external
+ user = User.find_by(id: current_user.id)
+ @external_user_transactions = user.transactions.where(group_id: nil).order(created_at: :desc)
+ @external_total = @external_user_transactions.sum(:amount)
+ end
+
+ def friends
+ @users = User.where.not(id: current_user.id)
+ @expenses = Expense.where.not(user_id: current_user.id)
+ end
end
diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb
index c1f5d90..4fa8aed 100644
--- a/app/controllers/transactions_controller.rb
+++ b/app/controllers/transactions_controller.rb
@@ -2,8 +2,12 @@ class TransactionsController < ApplicationController
before_action :authenticate_user!
def index
- @transaction = current_user.transactions.all.sort_by(&:created_at).reverse
- @total = current_user.transactions.sum(:amount)
+ @transaction = current_user.transactions.all
+ @other_transaction = @transaction.where.not(group_id: nil)
+ @other_transaction_sorted = @other_transaction.sort_by(&:created_at).reverse
+
+ @total = @other_transaction.sum(:amount)
+
end
def new
@@ -11,13 +15,14 @@ def new
end
def create
+
@transaction = current_user.transactions.new(transaction_params)
if @transaction.save
if @transaction.group_id.nil?
- redirect_to home_external_path, notice: 'Transaction expense was successfully created.'
+ redirect_to external_path, notice: 'Transaction expense was successfully created.'
else
@@ -56,11 +61,8 @@ def destroy
@transaction = current_user.transactions.find(params[:id])
@transaction.destroy
-
- respond_to do |format|
- format.html { redirect_to transactions_url, notice: 'Transaction was successfully destroyed.' }
- format.json { head :no_content }
- end
+ redirect_back(fallback_location: root_path)
+
end
diff --git a/app/views/static_pages/external.html.erb b/app/views/static_pages/external.html.erb
new file mode 100644
index 0000000..7e996e6
--- /dev/null
+++ b/app/views/static_pages/external.html.erb
@@ -0,0 +1,67 @@
+ $ <%= t.amount %> <%= t.created_at %>most recent
+
+ <%= t.name %>
+
+
+
+
+<%= link_to "Add new", new_transaction_path , :class => "btn btn-success new_trans" %>
+