-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from deyemiobaa/dev
Rails budget app
- Loading branch information
Showing
68 changed files
with
2,081 additions
and
957 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 |
---|---|---|
|
@@ -34,3 +34,6 @@ | |
!/app/assets/builds/.keep | ||
|
||
/node_modules | ||
|
||
# Ignore application configuration | ||
/config/application.yml |
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
//= require activestorage | ||
|
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,40 @@ | ||
|
||
// direct_uploads.js | ||
|
||
addEventListener("direct-upload:initialize", event => { | ||
const { target, detail } = event | ||
const { id, file } = detail | ||
target.insertAdjacentHTML("beforebegin", ` | ||
<div id="direct-upload-${id}" class="direct-upload direct-upload--pending"> | ||
<div id="direct-upload-progress-${id}" class="direct-upload__progress" style="width: 0%"></div> | ||
<span class="direct-upload__filename"></span> | ||
</div> | ||
`) | ||
target.previousElementSibling.querySelector(`.direct-upload__filename`).textContent = file.name | ||
}) | ||
|
||
addEventListener("direct-upload:start", event => { | ||
const { id } = event.detail | ||
const element = document.getElementById(`direct-upload-${id}`) | ||
element.classList.remove("direct-upload--pending") | ||
}) | ||
|
||
addEventListener("direct-upload:progress", event => { | ||
const { id, progress } = event.detail | ||
const progressElement = document.getElementById(`direct-upload-progress-${id}`) | ||
progressElement.style.width = `${progress}%` | ||
}) | ||
|
||
addEventListener("direct-upload:error", event => { | ||
event.preventDefault() | ||
const { id, error } = event.detail | ||
const element = document.getElementById(`direct-upload-${id}`) | ||
element.classList.add("direct-upload--error") | ||
element.setAttribute("title", error) | ||
}) | ||
|
||
addEventListener("direct-upload:end", event => { | ||
const { id } = event.detail | ||
const element = document.getElementById(`direct-upload-${id}`) | ||
element.classList.add("direct-upload--complete") | ||
}) |
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,4 +1,7 @@ | ||
/* stylelint-disable */ | ||
|
||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@300;700&display=swap'); | ||
|
||
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@300;700&display=swap'); |
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,2 +1,11 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery with: :exception | ||
before_action :configure_permitted_parameters, if: :devise_controller? | ||
before_action :authenticate_user! | ||
|
||
protected | ||
|
||
def configure_permitted_parameters | ||
devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :password, :password_confirmation) } | ||
end | ||
end |
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
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,3 +1,4 @@ | ||
class WelcomeController < ApplicationController | ||
skip_before_action :authenticate_user! | ||
def index; end | ||
end |
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,3 +1,16 @@ | ||
class Category < ApplicationRecord | ||
has_one_attached :icon | ||
has_many :payments, dependent: :destroy | ||
belongs_to :user | ||
validates :name, presence: true | ||
validates :icon, presence: true | ||
validates :user_id, presence: true | ||
|
||
def total_amount(user) | ||
payments.includes(:user).where(user:).sum(:amount) | ||
end | ||
|
||
def sorted_payments(user) | ||
payments.includes(:user).where(user:).order(created_at: :desc) | ||
end | ||
end |
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,2 +1,12 @@ | ||
class Payment < ApplicationRecord | ||
belongs_to :user | ||
belongs_to :category | ||
validates :amount, presence: true | ||
validates :amount, numericality: { greater_than: 0 } | ||
validates :category_id, presence: true | ||
validates :name, presence: true | ||
|
||
def payment_date | ||
created_at.strftime('%d %b %Y') | ||
end | ||
end |
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,6 +1,7 @@ | ||
class User < ApplicationRecord | ||
# Include default devise modules. Others available are: | ||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable | ||
devise :database_authenticatable, :registerable, | ||
:recoverable, :rememberable, :validatable | ||
has_many :categories, dependent: :destroy | ||
has_many :payments, dependent: :destroy | ||
validates :name, presence: true, length: { minimum: 3, maximum: 25 } | ||
|
||
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable | ||
end |
Oops, something went wrong.