├── log └── .keep ├── storage └── .keep ├── tmp ├── .keep ├── pids │ └── .keep └── storage │ └── .keep ├── vendor ├── .keep └── javascript │ └── .keep ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── apple-touch-icon.png ├── apple-touch-icon-precomposed.png ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── app ├── assets │ ├── builds │ │ └── .keep │ ├── images │ │ └── .keep │ ├── config │ │ └── manifest.js │ └── stylesheets │ │ ├── application.css │ │ └── application.tailwind.css ├── models │ ├── concerns │ │ └── .keep │ ├── application_record.rb │ ├── ability.rb │ ├── group.rb │ ├── spend.rb │ └── user.rb ├── controllers │ ├── concerns │ │ └── .keep │ ├── splashes_controller.rb │ ├── application_controller.rb │ ├── users_controller.rb │ ├── groups_controller.rb │ └── spends_controller.rb ├── views │ ├── layouts │ │ ├── mailer.text.erb │ │ ├── mailer.html.erb │ │ └── application.html.erb │ ├── users │ │ ├── show.json.jbuilder │ │ ├── index.json.jbuilder │ │ ├── _user.json.jbuilder │ │ ├── _user.html.erb │ │ ├── new.html.erb │ │ ├── edit.html.erb │ │ ├── show.html.erb │ │ ├── index.html.erb │ │ └── _form.html.erb │ ├── groups │ │ ├── show.json.jbuilder │ │ ├── index.json.jbuilder │ │ ├── _group.json.jbuilder │ │ ├── new.html.erb │ │ ├── edit.html.erb │ │ ├── show.html.erb │ │ ├── _group.html.erb │ │ ├── index.html.erb │ │ └── _form.html.erb │ ├── spends │ │ ├── show.json.jbuilder │ │ ├── index.json.jbuilder │ │ ├── _spend.json.jbuilder │ │ ├── new.html.erb │ │ ├── edit.html.erb │ │ ├── show.html.erb │ │ ├── _spend.html.erb │ │ ├── index.html.erb │ │ └── _form.html.erb │ ├── devise │ │ ├── mailer │ │ │ ├── password_change.html.erb │ │ │ ├── unlock_instructions.html.erb │ │ │ ├── email_changed.html.erb │ │ │ ├── reset_password_instructions.html.erb │ │ │ └── confirmation_instructions.html.erb │ │ ├── shared │ │ │ ├── _error_messages.html.erb │ │ │ └── _links.html.erb │ │ ├── unlocks │ │ │ └── new.html.erb │ │ ├── confirmations │ │ │ └── new.html.erb │ │ ├── passwords │ │ │ ├── new.html.erb │ │ │ └── edit.html.erb │ │ ├── registrations │ │ │ ├── new.html.erb │ │ │ └── edit.html.erb │ │ └── sessions │ │ │ └── new.html.erb │ ├── shared │ │ └── _navbar.html.erb │ └── splashes │ │ └── index.html.erb ├── helpers │ ├── users_helper.rb │ ├── groups_helper.rb │ ├── spends_helper.rb │ ├── splashes_helper.rb │ └── application_helper.rb ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── mailers │ └── application_mailer.rb ├── javascript │ ├── application.js │ └── controllers │ │ ├── hello_controller.js │ │ ├── application.js │ │ └── index.js └── jobs │ └── application_job.rb ├── .ruby-version ├── .stylelintignore ├── Procfile.dev ├── murple_logo.png ├── bin ├── importmap ├── rake ├── dev ├── render-build.sh ├── rails ├── setup ├── bundle └── bundle.cmd ├── config.ru ├── config ├── environment.rb ├── cable.yml ├── boot.rb ├── routes.rb ├── credentials.yml.enc ├── initializers │ ├── filter_parameter_logging.rb │ ├── permissions_policy.rb │ ├── assets.rb │ ├── inflections.rb │ ├── content_security_policy.rb │ └── devise.rb ├── importmap.rb ├── tailwind.config.js ├── application.rb ├── locales │ ├── en.yml │ └── devise.en.yml ├── storage.yml ├── puma.rb ├── environments │ ├── test.rb │ ├── development.rb │ └── production.rb └── database.yml ├── db ├── migrate │ ├── 20221121214353_rename_column_user_id_spends.rb │ ├── 20221121213203_add_user_ref_to_groups.rb │ ├── 20221121213515_add_user_ref_to_spends.rb │ ├── 20221121214642_change_amount_default_value.rb │ ├── 20221121204930_create_users.rb │ ├── 20221121211512_create_groups.rb │ ├── 20221121211854_create_spends.rb │ ├── 20221121213704_create_join_table_group_spend.rb │ └── 20221121225119_add_devise_columns_to_user.rb ├── seeds.rb └── schema.rb ├── .gitattributes ├── Rakefile ├── spec ├── requests │ ├── splashes_spec.rb │ ├── spends_spec.rb │ └── groups_spec.rb ├── routing │ ├── spends_routing_spec.rb │ ├── users_routing_spec.rb │ └── groups_routing_spec.rb ├── models │ ├── user_spec.rb │ ├── spend_spec.rb │ └── group_spec.rb ├── rails_helper.rb └── spec_helper.rb ├── package.json ├── .stylelintrc.json ├── .gitignore ├── LICENSE ├── .rubocop.yml ├── .github └── workflows │ └── linters.yml ├── Gemfile ├── README.md └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/pids/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/builds/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/javascript/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | ruby-3.1.2 2 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/helpers/users_helper.rb: -------------------------------------------------------------------------------- 1 | module UsersHelper 2 | end 3 | -------------------------------------------------------------------------------- /.stylelintignore: -------------------------------------------------------------------------------- 1 | app/assets/builds/tailwind.css 2 | coverage/* -------------------------------------------------------------------------------- /app/helpers/groups_helper.rb: -------------------------------------------------------------------------------- 1 | module GroupsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/spends_helper.rb: -------------------------------------------------------------------------------- 1 | module SpendsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/splashes_helper.rb: -------------------------------------------------------------------------------- 1 | module SplashesHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /Procfile.dev: -------------------------------------------------------------------------------- 1 | web: rails server -p 3000 2 | css: rails tailwindcss:watch 3 | -------------------------------------------------------------------------------- /app/views/users/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.partial! 'users/user', user: @user 2 | -------------------------------------------------------------------------------- /app/views/groups/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.partial! 'groups/group', group: @group 2 | -------------------------------------------------------------------------------- /app/views/spends/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.partial! 'spends/spend', spend: @spend 2 | -------------------------------------------------------------------------------- /murple_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VaneCode/money_moves/HEAD/murple_logo.png -------------------------------------------------------------------------------- /app/views/users/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array! @users, partial: 'users/user', as: :user 2 | -------------------------------------------------------------------------------- /app/views/groups/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array! @groups, partial: 'groups/group', as: :group 2 | -------------------------------------------------------------------------------- /app/views/spends/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array! @spends, partial: 'spends/spend', as: :spend 2 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | primary_abstract_class 3 | end 4 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/views/users/_user.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! user, :id, :name, :created_at, :updated_at 2 | json.url user_url(user, format: :json) 3 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/views/groups/_group.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! group, :id, :icon, :name, :created_at, :updated_at 2 | json.url group_url(group, format: :json) 3 | -------------------------------------------------------------------------------- /app/views/spends/_spend.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! spend, :id, :name, :amount, :created_at, :updated_at 2 | json.url spend_url(spend, format: :json) 3 | -------------------------------------------------------------------------------- /app/views/users/_user.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

3 | Name: 4 | <%= user.name %> 5 |

6 | 7 |
8 | -------------------------------------------------------------------------------- /bin/importmap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require_relative '../config/application' 5 | require 'importmap/commands' 6 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby.exe 2 | # frozen_string_literal: true 3 | 4 | require_relative '../config/boot' 5 | require 'rake' 6 | Rake.application.run 7 | -------------------------------------------------------------------------------- /app/controllers/splashes_controller.rb: -------------------------------------------------------------------------------- 1 | class SplashesController < ApplicationController 2 | def index 3 | redirect_to groups_path if user_signed_in? 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/views/devise/mailer/password_change.html.erb: -------------------------------------------------------------------------------- 1 |

Hello <%= @resource.email %>!

2 | 3 |

We're contacting you to notify you that your password has been changed.

4 | -------------------------------------------------------------------------------- /app/views/users/new.html.erb: -------------------------------------------------------------------------------- 1 |

New user

2 | 3 | <%= render "form", user: @user %> 4 | 5 |
6 | 7 |
8 | <%= link_to "Back to users", users_path %> 9 |
10 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /app/javascript/application.js: -------------------------------------------------------------------------------- 1 | // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails 2 | import "@hotwired/turbo-rails" 3 | import "controllers" 4 | -------------------------------------------------------------------------------- /bin/dev: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | if ! gem list foreman -i --silent; then 4 | echo "Installing foreman..." 5 | gem install foreman 6 | fi 7 | 8 | exec foreman start -f Procfile.dev "$@" 9 | -------------------------------------------------------------------------------- /bin/render-build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # exit on error 3 | set -o errexit 4 | 5 | bundle install 6 | bundle exec rake assets:precompile 7 | bundle exec rake assets:clean 8 | bundle exec rake db:migrate -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Load the Rails application. 4 | require_relative 'application' 5 | 6 | # Initialize the Rails application. 7 | Rails.application.initialize! 8 | -------------------------------------------------------------------------------- /app/views/groups/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= render "form", group: @group %> 3 |
4 | 5 |
6 | <%= link_to "Back to categories", groups_path %> 7 |
8 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby.exe 2 | # frozen_string_literal: true 3 | 4 | APP_PATH = File.expand_path('../config/application', __dir__) 5 | require_relative '../config/boot' 6 | require 'rails/commands' 7 | -------------------------------------------------------------------------------- /db/migrate/20221121214353_rename_column_user_id_spends.rb: -------------------------------------------------------------------------------- 1 | class RenameColumnUserIdSpends < ActiveRecord::Migration[7.0] 2 | def change 3 | rename_column :spends, :user_id, :author_id 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../stylesheets .css 3 | //= link_tree ../../javascript .js 4 | //= link_tree ../../../vendor/javascript .js 5 | //= link_tree ../builds 6 | -------------------------------------------------------------------------------- /db/migrate/20221121213203_add_user_ref_to_groups.rb: -------------------------------------------------------------------------------- 1 | class AddUserRefToGroups < ActiveRecord::Migration[7.0] 2 | def change 3 | add_reference :groups, :user, null: false, foreign_key: true 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20221121213515_add_user_ref_to_spends.rb: -------------------------------------------------------------------------------- 1 | class AddUserRefToSpends < ActiveRecord::Migration[7.0] 2 | def change 3 | add_reference :spends, :user, null: false, foreign_key: true 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20221121214642_change_amount_default_value.rb: -------------------------------------------------------------------------------- 1 | class ChangeAmountDefaultValue < ActiveRecord::Migration[7.0] 2 | def change 3 | change_column_default(:spends, :amount, from: nil, to: 0) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/javascript/controllers/hello_controller.js: -------------------------------------------------------------------------------- 1 | import { Controller } from "@hotwired/stimulus" 2 | 3 | export default class extends Controller { 4 | connect() { 5 | this.element.textContent = "Hello World!" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /db/migrate/20221121204930_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration[7.0] 2 | def change 3 | create_table :users do |t| 4 | t.string :name 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /app/views/spends/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 3 | <%= render "form", spend: @spend %> 4 | 5 |
6 | 7 |
8 | <%= link_to "Back to category", group_spends_path(@group) %> 9 |
10 | -------------------------------------------------------------------------------- /app/views/users/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing user

2 | 3 | <%= render "form", user: @user %> 4 | 5 |
6 | 7 |
8 | <%= link_to "Show this user", @user %> | 9 | <%= link_to "Back to users", users_path %> 10 |
11 | -------------------------------------------------------------------------------- /app/views/groups/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing group

2 | 3 | <%= render "form", group: @group %> 4 | 5 |
6 | 7 |
8 | <%= link_to "Show this group", @group %> | 9 | <%= link_to "Back to groups", groups_path %> 10 |
11 | -------------------------------------------------------------------------------- /app/views/spends/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing spend

2 | 3 | <%= render "form", spend: @spend %> 4 | 5 |
6 | 7 |
8 | <%= link_to "Show this spend", @spend %> | 9 | <%= link_to "Back to spends", spends_path %> 10 |
11 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: money_moves_production 11 | -------------------------------------------------------------------------------- /db/migrate/20221121211512_create_groups.rb: -------------------------------------------------------------------------------- 1 | class CreateGroups < ActiveRecord::Migration[7.0] 2 | def change 3 | create_table :groups do |t| 4 | t.string :icon 5 | t.string :name 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /app/models/ability.rb: -------------------------------------------------------------------------------- 1 | class Ability 2 | include CanCan::Ability 3 | def initialize(user) 4 | return unless user.present? 5 | 6 | can :manage, Group, user: user 7 | can :manage, Spend, author: user 8 | can :manage, User 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20221121211854_create_spends.rb: -------------------------------------------------------------------------------- 1 | class CreateSpends < ActiveRecord::Migration[7.0] 2 | def change 3 | create_table :spends do |t| 4 | t.string :name 5 | t.decimal :amount 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 4 | 5 | require 'bundler/setup' # Set up gems listed in the Gemfile. 6 | require 'bootsnap/setup' # Speed up boot time by caching expensive operations. 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # See https://git-scm.com/docs/gitattributes for more about git attribute files. 2 | 3 | # Mark the database schema as having been generated. 4 | db/schema.rb linguist-generated 5 | 6 | # Mark any vendored files as having been vendored. 7 | vendor/* linguist-vendored 8 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Add your own tasks in files placed in lib/tasks ending in .rake, 4 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 5 | 6 | require_relative 'config/application' 7 | 8 | Rails.application.load_tasks 9 | -------------------------------------------------------------------------------- /spec/requests/splashes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe 'Splashes', type: :request do 4 | describe 'GET /index' do 5 | it 'returns http success' do 6 | get '/' 7 | expect(response).to have_http_status(:success) 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "stylelint": "^13.13.1", 4 | "stylelint-config-standard": "^21.0.0", 5 | "stylelint-csstree-validator": "^1.9.0", 6 | "stylelint-scss": "^3.21.0" 7 | }, 8 | "dependencies": { 9 | "flowbite": "^1.5.4" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /app/javascript/controllers/application.js: -------------------------------------------------------------------------------- 1 | import { Application } from "@hotwired/stimulus" 2 | 3 | const application = Application.start() 4 | 5 | // Configure Stimulus development experience 6 | application.debug = false 7 | window.Stimulus = application 8 | 9 | export { application } 10 | -------------------------------------------------------------------------------- /db/migrate/20221121213704_create_join_table_group_spend.rb: -------------------------------------------------------------------------------- 1 | class CreateJoinTableGroupSpend < ActiveRecord::Migration[7.0] 2 | def change 3 | create_join_table :groups, :spends do |t| 4 | # t.index [:group_id, :spend_id] 5 | # t.index [:spend_id, :group_id] 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/users/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 | <%= render @user %> 4 | 5 |
6 | <%= link_to "Edit this user", edit_user_path(@user) %> | 7 | <%= link_to "Back to users", users_path %> 8 | 9 | <%= button_to "Destroy this user", @user, method: :delete %> 10 |
11 | -------------------------------------------------------------------------------- /app/views/groups/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 | <%= render @group %> 4 | 5 |
6 | <%= link_to "Edit this group", edit_group_path(@group) %> | 7 | <%= link_to "Back to groups", groups_path %> 8 | 9 | <%= button_to "Destroy this group", @group, method: :delete %> 10 |
11 | -------------------------------------------------------------------------------- /app/views/spends/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 | <%= render @spend %> 4 | 5 |
6 | <%= link_to "Edit this spend", edit_spend_path(@spend) %> | 7 | <%= link_to "Back to spends", spends_path %> 8 | 9 | <%= button_to "Destroy this spend", @spend, method: :delete %> 10 |
11 | -------------------------------------------------------------------------------- /app/views/users/index.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

Users

4 | 5 |
6 | <% @users.each do |user| %> 7 | <%= render user %> 8 |

9 | <%= link_to "Show this user", user %> 10 |

11 | <% end %> 12 |
13 | 14 | <%= link_to "New user", new_user_path %> 15 | -------------------------------------------------------------------------------- /app/models/group.rb: -------------------------------------------------------------------------------- 1 | class Group < ApplicationRecord 2 | # Associations 3 | belongs_to :user 4 | has_and_belongs_to_many :spends 5 | # Validations 6 | validates :name, presence: true, uniqueness: { scope: :user } 7 | validates :icon, presence: true 8 | # Method 9 | def calc_total 10 | spends.sum(:amount) 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /app/views/devise/mailer/unlock_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

Hello <%= @resource.email %>!

2 | 3 |

Your account has been locked due to an excessive number of unsuccessful sign in attempts.

4 | 5 |

Click the link below to unlock your account:

6 | 7 |

<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>

8 | -------------------------------------------------------------------------------- /app/views/devise/mailer/email_changed.html.erb: -------------------------------------------------------------------------------- 1 |

Hello <%= @email %>!

2 | 3 | <% if @resource.try(:unconfirmed_email?) %> 4 |

We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.

5 | <% else %> 6 |

We're contacting you to notify you that your email has been changed to <%= @resource.email %>.

7 | <% end %> 8 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | Rails.application.routes.draw do 4 | # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html 5 | devise_for :users # Routes for authentication 6 | root "splashes#index" # Defines the root path route ("/") 7 | resources :groups do 8 | resources :spends 9 | end 10 | resources :users 11 | end 12 | 13 | -------------------------------------------------------------------------------- /app/views/shared/_navbar.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/spend.rb: -------------------------------------------------------------------------------- 1 | class Spend < ApplicationRecord 2 | # Associations 3 | belongs_to :author, class_name: 'User' 4 | has_and_belongs_to_many :groups 5 | # Validations 6 | validates_associated :groups 7 | validates_presence_of :groups 8 | validates :name, :amount, presence: true 9 | validates :name, uniqueness: { scope: :author } 10 | validates :amount, numericality: { greater_than_or_equal_to: 0, less_than: BigDecimal(10**3) } 11 | end 12 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery with: :exception 3 | 4 | before_action :configure_permitted_parameters, if: :devise_controller? 5 | 6 | protected 7 | 8 | def configure_permitted_parameters 9 | attributes = %i[name email password password_confirmation current_password] 10 | devise_parameter_sanitizer.permit(:sign_up, keys: attributes) 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /app/views/devise/mailer/reset_password_instructions.html.erb: -------------------------------------------------------------------------------- 1 |

Hello <%= @resource.email %>!

2 | 3 |

Someone has requested a link to change your password. You can do this through the link below.

4 | 5 |

<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

6 | 7 |

If you didn't request this, please ignore this email.

8 |

Your password won't change until you access the link above and create a new one.

9 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | neLfErHYYXnGGy1Q6FkxN3xBwoAsJygTNFRrC4Yp+r7N6/U9d2O/XY65F8EbPLS/b1CJUZ6Ol+oXEJQB54uSUo6XLgx7ruv7cYA9DYVAXkUHswikxef6eQIeaYoZUBDcVjxEj8C03YtfukYDBjMMrdCC+iX1RIfpRG5HTm9JqqUg3mq8k1gPhQTgH2wShrryoOuI36HrziIlQcLVU3UxO1u3BmwRkE1qNj+6b+JonqIJy4lxTm5/sH92J3tcBp7strLBgQqK3U6nI+060mN+Gs/hUdRB0ssNZCWzYwYOeX3SCGf0tdFcz0JKtITQXHulOqbM8j1kdk7cV+/A6MBzwbp7w7U2TvQyrFsFhsqfBAELETHxt7ol7KQ80DBzbQfZAJd2VMZtA8gtcpp+ll3jLM7uh/nlXW4WU2MP--qgJLn3iQ2J+pZIOD--1ZMtmLUvUT2EjIsE72FKXQ== -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Be sure to restart your server when you modify this file. 4 | 5 | # Configure parameters to be filtered from the log file. Use this to limit dissemination of 6 | # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported 7 | # notations and behaviors. 8 | Rails.application.config.filter_parameters += %i[ 9 | passw secret token _key crypt salt certificate otp ssn 10 | ] 11 | -------------------------------------------------------------------------------- /app/views/splashes/index.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Money moves

4 |
5 |
6 | <%= link_to 'Log in', new_user_session_path, class: 'btn btn-primary' %> 7 | <%= link_to 'Sign up', new_user_registration_path, class: 'btn' %> 8 |
9 |
-------------------------------------------------------------------------------- /config/importmap.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Pin npm packages by running ./bin/importmap 4 | 5 | pin 'application', preload: true 6 | pin '@hotwired/turbo-rails', to: 'turbo.min.js', preload: true 7 | pin '@hotwired/stimulus', to: 'stimulus.min.js', preload: true 8 | pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js', preload: true 9 | pin_all_from 'app/javascript/controllers', under: 'controllers' 10 | pin "flowbite", to: "https://ga.jspm.io/npm:flowbite@1.5.3/dist/flowbite.js" -------------------------------------------------------------------------------- /config/initializers/permissions_policy.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Define an application-wide HTTP permissions policy. For further 3 | # information see https://developers.google.com/web/updates/2018/06/feature-policy 4 | # 5 | # Rails.application.config.permissions_policy do |f| 6 | # f.camera :none 7 | # f.gyroscope :none 8 | # f.microphone :none 9 | # f.usb :none 10 | # f.fullscreen :self 11 | # f.payment :self, "https://secure.example.com" 12 | # end 13 | -------------------------------------------------------------------------------- /app/views/devise/shared/_error_messages.html.erb: -------------------------------------------------------------------------------- 1 | <% if resource.errors.any? %> 2 |
3 |

4 | <%= I18n.t("errors.messages.not_saved", 5 | count: resource.errors.count, 6 | resource: resource.class.model_name.human.downcase) 7 | %> 8 |

9 | 14 |
15 | <% end %> 16 | -------------------------------------------------------------------------------- /spec/routing/spends_routing_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe SpendsController, type: :routing do 4 | describe 'routing' do 5 | it 'routes to #index' do 6 | expect(get: '/groups/1/spends').to route_to('spends#index', group_id: '1') 7 | end 8 | 9 | it 'routes to #new' do 10 | expect(get: '/groups/1/spends/new').to route_to('spends#new', group_id: '1') 11 | end 12 | 13 | it 'routes to #create' do 14 | expect(post: '/groups/1/spends').to route_to('spends#create', group_id: '1') 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/views/devise/unlocks/new.html.erb: -------------------------------------------------------------------------------- 1 |

Resend unlock instructions

2 | 3 | <%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> 4 | <%= render "devise/shared/error_messages", resource: resource %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true, autocomplete: "email" %> 9 |
10 | 11 |
12 | <%= f.submit "Resend unlock instructions" %> 13 |
14 | <% end %> 15 | 16 | <%= render "devise/shared/links" %> 17 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User < ApplicationRecord 2 | # Include default devise modules. Others available are: 3 | # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable 4 | devise :database_authenticatable, :registerable, 5 | :recoverable, :rememberable, :validatable 6 | # Associations 7 | has_many :spends, foreign_key: 'author_id', dependent: :destroy 8 | has_many :groups, dependent: :destroy 9 | # Validations 10 | validates :name, presence: true 11 | # Methods 12 | def calc_total_spends 13 | spends.sum(:amount) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Be sure to restart your server when you modify this file. 4 | 5 | # Version of your assets, change this if you want to expire all your assets. 6 | Rails.application.config.assets.version = '1.0' 7 | 8 | # Add additional assets to the asset load path. 9 | # Rails.application.config.assets.paths << Emoji.images_path 10 | 11 | # Precompile additional assets. 12 | # application.js, application.css, and all non-JS/CSS in the app/assets 13 | # folder are already added. 14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 15 | -------------------------------------------------------------------------------- /app/views/users/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with(model: user) do |form| %> 2 | <% if user.errors.any? %> 3 |
4 |

<%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:

5 | 6 | 11 |
12 | <% end %> 13 | 14 |
15 | <%= form.label :name, style: "display: block" %> 16 | <%= form.text_field :name %> 17 |
18 | 19 |
20 | <%= form.submit %> 21 |
22 | <% end %> 23 | -------------------------------------------------------------------------------- /app/views/devise/mailer/confirmation_instructions.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= link_to :back, class: "flex items-center justify-center p-2" do %> 3 | 4 | <% end %> 5 |

CONFIRM ACCOUNT

6 | <%= link_to 'Confirm', confirmation_url(@resource, confirmation_token: @token) %> 7 |
8 |
9 |

Welcome <%= @email %>!

10 |

You can confirm your account email through the link below:

11 | <%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %> 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # This file should contain all the record creation needed to seed the database with its default values. 3 | # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). 4 | # 5 | # Examples: 6 | # 7 | # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) 8 | # Character.create(name: "Luke", movie: movies.first) 9 | #Inventories 10 | 5.times do 11 | Group.create do |group| 12 | group.name = Faker::Lorem.word 13 | group.icon = 'car-side' 14 | group.user = User.first 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/views/spends/_spend.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 | <%= spend.name %> 6 | 7 | 8 | <%= number_to_currency(spend.amount) %> 9 | 10 |
11 |
12 | <%= spend.created_at.strftime('%Y-%m-%d') %> 13 |
14 |
15 |
16 | -------------------------------------------------------------------------------- /app/javascript/controllers/index.js: -------------------------------------------------------------------------------- 1 | // Import and register all your controllers from the importmap under controllers/* 2 | 3 | import { application } from "controllers/application" 4 | 5 | // Eager load all controllers defined in the import map under controllers/**/*_controller 6 | import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" 7 | eagerLoadControllersFrom("controllers", application) 8 | 9 | // Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!) 10 | // import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading" 11 | // lazyLoadControllersFrom("controllers", application) 12 | -------------------------------------------------------------------------------- /app/views/devise/confirmations/new.html.erb: -------------------------------------------------------------------------------- 1 |

Resend confirmation instructions

2 | 3 | <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> 4 | <%= render "devise/shared/error_messages", resource: resource %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %> 9 |
10 | 11 |
12 | <%= f.submit "Resend confirmation instructions" %> 13 |
14 | <% end %> 15 | 16 | <%= render "devise/shared/links" %> 17 | -------------------------------------------------------------------------------- /spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe User, type: :model do 4 | subject do 5 | User.new(name: 'Samantha Woods', email: 'sam@outlook.com', password: 'password', 6 | password_confirmation: 'password') 7 | end 8 | 9 | before { subject.save } 10 | 11 | context 'Test user validations' do 12 | it 'is a user with valid attributes' do 13 | expect(subject).to be_valid 14 | end 15 | 16 | it 'name should be present' do 17 | subject.name = nil 18 | expect(subject).to_not be_valid 19 | end 20 | 21 | it 'email should be an string' do 22 | expect(subject.email).to be_a_kind_of(String) 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Be sure to restart your server when you modify this file. 3 | 4 | # Add new inflection rules using the following format. Inflections 5 | # are locale specific, and you may define rules for as many different 6 | # locales as you wish. All of these examples are active by default: 7 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 8 | # inflect.plural /^(ox)$/i, "\\1en" 9 | # inflect.singular /^(ox)en/i, "\\1" 10 | # inflect.irregular "person", "people" 11 | # inflect.uncountable %w( fish sheep ) 12 | # end 13 | 14 | # These inflection rules are supported but not enabled by default: 15 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 16 | # inflect.acronym "RESTful" 17 | # end 18 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /app/views/devise/passwords/new.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> 2 |
3 | <%= link_to :back, class: "flex items-center justify-center p-2" do %> 4 | 5 | <% end %> 6 |

RECOVER PASSWORD

7 | <%= f.submit "Reset" %> 8 |
9 |
10 | <%= render "devise/shared/error_messages", resource: resource %> 11 | 12 |
13 | <%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: "Email", class: 'input-field' %> 14 |
15 | 16 |
17 | <%= render "devise/shared/links" %> 18 |
19 | <% end %> 20 | 21 | 22 | -------------------------------------------------------------------------------- /config/tailwind.config.js: -------------------------------------------------------------------------------- 1 | const defaultTheme = require('tailwindcss/defaultTheme') 2 | 3 | module.exports = { 4 | content: [ 5 | './public/*.html', 6 | './app/helpers/**/*.rb', 7 | './app/javascript/**/*.js', 8 | './app/views/**/*.{erb,haml,html,slim}', 9 | ], 10 | theme: { 11 | extend: { 12 | fontFamily: { 13 | sans: ['Montserrat', ...defaultTheme.fontFamily.sans], 14 | }, 15 | colors: { 16 | transparent: 'transparent', 17 | current: 'currentColor', 18 | 'solid-blue': '#3778c2', 19 | 'solid-green': '#5fb523', 20 | 'solid-grey': '#434b54', 21 | }, 22 | }, 23 | }, 24 | plugins: [ 25 | require('@tailwindcss/forms'), 26 | require('@tailwindcss/aspect-ratio'), 27 | require('@tailwindcss/typography'), 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Money Moves 5 | 6 | <%= csrf_meta_tags %> 7 | <%= csp_meta_tag %> 8 | <%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> 9 | 10 | <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> 11 | <%= javascript_importmap_tags %> 12 | 13 | 14 | 15 | 16 | <% if user_signed_in? %> 17 | <%= render 'shared/navbar' %> 18 | <% end %> 19 |
20 | <%= yield %> 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /.stylelintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["stylelint-config-standard"], 3 | "plugins": ["stylelint-scss", "stylelint-csstree-validator"], 4 | "rules": { 5 | "at-rule-no-unknown": [ 6 | true, 7 | { 8 | "ignoreAtRules": [ 9 | "tailwind", 10 | "apply", 11 | "variants", 12 | "responsive", 13 | "screen", 14 | "layer" 15 | ] 16 | } 17 | ], 18 | "scss/at-rule-no-unknown": [ 19 | true, 20 | { 21 | "ignoreAtRules": [ 22 | "tailwind", 23 | "apply", 24 | "variants", 25 | "responsive", 26 | "screen", 27 | "layer" 28 | ] 29 | } 30 | ], 31 | "csstree/validator": true 32 | }, 33 | "ignoreFiles": ["build/**", "dist/**", "**/reset*.css", "**/bootstrap*.css"] 34 | } -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative 'boot' 4 | 5 | require 'rails/all' 6 | 7 | # Require the gems listed in Gemfile, including any gems 8 | # you've limited to :test, :development, or :production. 9 | Bundler.require(*Rails.groups) 10 | 11 | module MoneyMoves 12 | class Application < Rails::Application 13 | # Initialize configuration defaults for originally generated Rails version. 14 | config.load_defaults 7.0 15 | 16 | # Configuration for the application, engines, and railties goes here. 17 | # 18 | # These settings can be overridden in specific environments using the files 19 | # in config/environments, which are processed later. 20 | # 21 | # config.time_zone = "Central Time (US & Canada)" 22 | # config.eager_load_paths << Rails.root.join("extras") 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /app/views/groups/_group.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 | <%= image_tag(group.icon, alt: "category icon", class: "img-fluid hover:scale-110 transition duration-300 ease-in-out") %> 4 |
5 | 6 |
7 |
8 | 9 | <%= group.name %> 10 | 11 | 12 | <%= number_to_currency(group.calc_total) %> 13 | 14 |
15 |
16 | <%= group.created_at.strftime('%Y-%m-%d') %> 17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /app/views/groups/index.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | User: <%= current_user.name %> 5 | 6 | 7 | Categories: <%= @groups.count %> 8 | 9 |
10 |

<%= notice %>

11 |
12 | <% if @groups.count > 0 %> 13 | <% @groups.each do |group| %> 14 | <%= link_to(group_spends_path(group)) do %> 15 | <%= render group %> 16 | <% end %> 17 | <% end %> 18 | <% else %> 19 |

You don't have categories yet.

20 | <% end %> 21 |
22 |
23 | <%= link_to "New category", new_group_path %> 24 |
25 |
26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/views/groups/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with(model: group) do |form| %> 2 | <% if group.errors.any? %> 3 |
4 |

<%= pluralize(group.errors.count, "error") %> prohibited this group from being saved:

5 | 6 | 11 |
12 | <% end %> 13 | 14 |
15 | <%= form.text_field :icon, autofocus: true, placeholder: "Icon url", class: 'input-field' %> 16 |
17 | 18 |
19 | <%= form.text_field :name, placeholder: "Name", class: 'input-field' %> 20 |
21 | 22 |
23 | <%= form.submit 'CREATE CATEGORY', class: 'input-submit'%> 24 |
25 | <% end %> 26 | -------------------------------------------------------------------------------- /app/views/spends/index.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | User: <%= current_user.name %> 5 | 6 | 7 | Total: <%= number_to_currency(@group.calc_total) %> 8 | 9 |
10 |

<%= notice %>

11 |
12 | <% if @spends.count > 0 %> 13 | <% @spends.each do |spend| %> 14 | <%= render spend %> 15 | <% end %> 16 | <% else %> 17 |

This category doesn't have transactions yet.

18 | <% end %> 19 |
20 |
21 |
22 | <%= link_to "Back to categories", groups_path%> 23 |
24 |
25 | <%= link_to "New transaction", new_group_spend_path(@group) %> 26 |
27 |
28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore .env 11 | .env 12 | 13 | # Ignore all logfiles and tempfiles. 14 | /log/* 15 | /tmp/* 16 | !/log/.keep 17 | !/tmp/.keep 18 | 19 | # Ignore pidfiles, but keep the directory. 20 | /tmp/pids/* 21 | !/tmp/pids/ 22 | !/tmp/pids/.keep 23 | 24 | # Ignore uploaded files in development. 25 | /storage/* 26 | !/storage/.keep 27 | /tmp/storage/* 28 | !/tmp/storage/ 29 | !/tmp/storage/.keep 30 | 31 | /public/assets 32 | 33 | # Ignore master key for decrypting credentials and more. 34 | /config/master.key 35 | 36 | # .gitignore 37 | node_modules/ 38 | 39 | /app/assets/builds/* 40 | !/app/assets/builds/.keep 41 | -------------------------------------------------------------------------------- /app/views/devise/passwords/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Change your password

2 | 3 | <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> 4 | <%= render "devise/shared/error_messages", resource: resource %> 5 | <%= f.hidden_field :reset_password_token %> 6 | 7 |
8 | <%= f.label :password, "New password" %>
9 | <% if @minimum_password_length %> 10 | (<%= @minimum_password_length %> characters minimum)
11 | <% end %> 12 | <%= f.password_field :password, autofocus: true, autocomplete: "new-password" %> 13 |
14 | 15 |
16 | <%= f.label :password_confirmation, "Confirm new password" %>
17 | <%= f.password_field :password_confirmation, autocomplete: "new-password" %> 18 |
19 | 20 |
21 | <%= f.submit "Change my password" %> 22 |
23 | <% end %> 24 | 25 | <%= render "devise/shared/links" %> 26 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t "hello" 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t("hello") %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # "true": "foo" 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at https://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /spec/routing/users_routing_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe UsersController, type: :routing do 4 | describe 'routing' do 5 | it 'routes to #index' do 6 | expect(get: '/users').to route_to('users#index') 7 | end 8 | 9 | it 'routes to #new' do 10 | expect(get: '/users/new').to route_to('users#new') 11 | end 12 | 13 | it 'routes to #show' do 14 | expect(get: '/users/1').to route_to('users#show', id: '1') 15 | end 16 | 17 | it 'routes to #edit' do 18 | expect(get: '/users/1/edit').to route_to('users#edit', id: '1') 19 | end 20 | 21 | it 'routes to #update via PUT' do 22 | expect(put: '/users/1').to route_to('users#update', id: '1') 23 | end 24 | 25 | it 'routes to #update via PATCH' do 26 | expect(patch: '/users/1').to route_to('users#update', id: '1') 27 | end 28 | 29 | it 'routes to #destroy' do 30 | expect(delete: '/users/1').to route_to('users#destroy', id: '1') 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /spec/models/spend_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Spend, type: :model do 4 | before do 5 | @user = User.create(name: 'Samantha Woods', email: 'sam@outlook.com', password: 'password', 6 | password_confirmation: 'password') 7 | @group = Group.create(name: 'Pets', icon: 'pet_img', user: @user) 8 | @spend = Spend.create(name: 'Pet food', amount: 45, author: @user) 9 | @spend.groups << @group 10 | end 11 | 12 | context 'Test spend validations' do 13 | it 'is a spend with valid attributes' do 14 | expect(@spend).to be_valid 15 | end 16 | 17 | it 'amount should be great or equal than 0' do 18 | @spend.amount = -1 19 | expect(@spend).to_not be_valid 20 | end 21 | 22 | it 'name should be present' do 23 | @spend.name = nil 24 | expect(@spend).to_not be_valid 25 | end 26 | 27 | it 'amount should be present' do 28 | @spend.amount = nil 29 | expect(@spend).to_not be_valid 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /app/views/spends/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with model: spend, url: group_spends_path(@group) do |form| %> 2 | <% if spend.errors.any? %> 3 |
4 |

<%= pluralize(spend.errors.count, "error") %> prohibited this spend from being saved:

5 | 6 | 11 |
12 | <% end %> 13 | 14 |
15 | <%= form.collection_check_boxes :group_ids, @groups, :id, :name, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full"%> 16 |
17 | 18 |
19 | <%= form.text_field :name, placeholder: "Name", class: 'input-field' %> 20 |
21 | 22 |
23 | <%= form.text_field :amount, class: 'input-field' %> 24 |
25 | 26 |
27 | <%= form.submit 'CREATE TRANSACTION', class: 'input-submit'%> 28 |
29 | <% end %> 30 | -------------------------------------------------------------------------------- /app/views/devise/registrations/new.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> 2 |
3 | <%= link_to :back, class: "flex items-center justify-center p-2" do %> 4 | 5 | <% end %> 6 |

REGISTER

7 | <%= f.submit "Next" %> 8 |
9 |
10 | <%= render "devise/shared/error_messages", resource: resource %> 11 |
12 | <%= f.text_field :name, autofocus: true, placeholder: 'Full name', class: 'input-field' %> 13 |
14 | 15 |
16 | <%= f.email_field :email, autocomplete: "email", placeholder: 'Email', class: 'input-field' %> 17 |
18 | 19 |
20 | <%= f.password_field :password, autocomplete: "new-password", placeholder: 'Password', class: 'input-field' %> 21 |
22 | 23 |
24 | <%= f.password_field :password_confirmation, autocomplete: "new-password", placeholder: 'Password confirmation', class: 'input-field' %> 25 |
26 | <% end %> 27 | 28 | -------------------------------------------------------------------------------- /spec/routing/groups_routing_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe GroupsController, type: :routing do 4 | describe 'routing' do 5 | it 'routes to #index' do 6 | expect(get: '/groups').to route_to('groups#index') 7 | end 8 | 9 | it 'routes to #new' do 10 | expect(get: '/groups/new').to route_to('groups#new') 11 | end 12 | 13 | it 'routes to #show' do 14 | expect(get: '/groups/1').to route_to('groups#show', id: '1') 15 | end 16 | 17 | it 'routes to #edit' do 18 | expect(get: '/groups/1/edit').to route_to('groups#edit', id: '1') 19 | end 20 | 21 | it 'routes to #create' do 22 | expect(post: '/groups').to route_to('groups#create') 23 | end 24 | 25 | it 'routes to #update via PUT' do 26 | expect(put: '/groups/1').to route_to('groups#update', id: '1') 27 | end 28 | 29 | it 'routes to #update via PATCH' do 30 | expect(patch: '/groups/1').to route_to('groups#update', id: '1') 31 | end 32 | 33 | it 'routes to #destroy' do 34 | expect(delete: '/groups/1').to route_to('groups#destroy', id: '1') 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Vanessa Bonito 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby.exe 2 | # frozen_string_literal: true 3 | 4 | require 'fileutils' 5 | 6 | # path to your application root. 7 | APP_ROOT = File.expand_path('..', __dir__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | FileUtils.chdir APP_ROOT do 14 | # This script is a way to set up or update your development environment automatically. 15 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 16 | # Add necessary setup steps to this file. 17 | 18 | puts '== Installing dependencies ==' 19 | system! 'gem install bundler --conservative' 20 | system('bundle check') || system!('bundle install') 21 | 22 | # puts "\n== Copying sample files ==" 23 | # unless File.exist?("config/database.yml") 24 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" 25 | # end 26 | 27 | puts "\n== Preparing database ==" 28 | system! 'bin/rails db:prepare' 29 | 30 | puts "\n== Removing old logs and tempfiles ==" 31 | system! 'bin/rails log:clear tmp:clear' 32 | 33 | puts "\n== Restarting application server ==" 34 | system! 'bin/rails restart' 35 | end 36 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Be sure to restart your server when you modify this file. 3 | 4 | # Define an application-wide content security policy. 5 | # See the Securing Rails Applications Guide for more information: 6 | # https://guides.rubyonrails.org/security.html#content-security-policy-header 7 | 8 | # Rails.application.configure do 9 | # config.content_security_policy do |policy| 10 | # policy.default_src :self, :https 11 | # policy.font_src :self, :https, :data 12 | # policy.img_src :self, :https, :data 13 | # policy.object_src :none 14 | # policy.script_src :self, :https 15 | # policy.style_src :self, :https 16 | # # Specify URI for violation reports 17 | # # policy.report_uri "/csp-violation-report-endpoint" 18 | # end 19 | # 20 | # # Generate session nonces for permitted importmap and inline scripts 21 | # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } 22 | # config.content_security_policy_nonce_directives = %w(script-src) 23 | # 24 | # # Report violations without enforcing the policy. 25 | # # config.content_security_policy_report_only = true 26 | # end 27 | -------------------------------------------------------------------------------- /spec/models/group_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Group, type: :model do 4 | before do 5 | @user = User.create(name: 'Samantha Woods', email: 'sam@outlook.com', password: 'password', 6 | password_confirmation: 'password') 7 | @group = Group.create(name: 'Pets', icon: 'pet_img', user: @user) 8 | @spend1 = Spend.create(name: 'Pet food', amount: 45, author: @user) 9 | @spend1.groups << @group 10 | @spend2 = Spend.create(name: 'Vet', amount: 50, author: @user) 11 | @spend2.groups << @group 12 | end 13 | 14 | context 'Test group validations' do 15 | it 'is a group with valid attributes' do 16 | expect(@group).to be_valid 17 | end 18 | 19 | it 'name should be present' do 20 | @group.name = nil 21 | expect(@group).to_not be_valid 22 | end 23 | 24 | it 'icon should be present' do 25 | @group.icon = nil 26 | expect(@group).to_not be_valid 27 | end 28 | end 29 | 30 | context 'Test methods in the model group' do 31 | it 'when the group does\'nt have spends the total has to be 0' do 32 | group = Group.create(name: 'Pets', icon: 'pet_img', user: @user) 33 | total = group.calc_total 34 | expect(total).to eq 0 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket-<%= Rails.env %> 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket-<%= Rails.env %> 23 | 24 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name-<%= Rails.env %> 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | NewCops: enable 3 | Exclude: 4 | - "db/**/*" 5 | - "bin/*" 6 | - "config/**/*" 7 | - "Guardfile" 8 | - "Rakefile" 9 | - "node_modules/**/*" 10 | 11 | DisplayCopNames: true 12 | 13 | Layout/LineLength: 14 | Max: 120 15 | Metrics/MethodLength: 16 | Include: 17 | - "app/controllers/*" 18 | - "app/models/*" 19 | Max: 20 20 | Metrics/AbcSize: 21 | Include: 22 | - "app/controllers/*" 23 | - "app/models/*" 24 | Max: 50 25 | Metrics/ClassLength: 26 | Max: 150 27 | Metrics/BlockLength: 28 | IgnoredMethods: ['describe'] 29 | Max: 30 30 | 31 | Style/Documentation: 32 | Enabled: false 33 | Style/ClassAndModuleChildren: 34 | Enabled: false 35 | Style/EachForSimpleLoop: 36 | Enabled: false 37 | Style/AndOr: 38 | Enabled: false 39 | Style/DefWithParentheses: 40 | Enabled: false 41 | Style/FrozenStringLiteralComment: 42 | EnforcedStyle: never 43 | 44 | Layout/HashAlignment: 45 | EnforcedColonStyle: key 46 | Layout/ExtraSpacing: 47 | AllowForAlignment: false 48 | Layout/MultilineMethodCallIndentation: 49 | Enabled: true 50 | EnforcedStyle: indented 51 | Lint/RaiseException: 52 | Enabled: false 53 | Lint/StructNewOverride: 54 | Enabled: false 55 | Style/HashEachMethods: 56 | Enabled: false 57 | Style/HashTransformKeys: 58 | Enabled: false 59 | Style/HashTransformValues: 60 | Enabled: false -------------------------------------------------------------------------------- /app/views/devise/shared/_links.html.erb: -------------------------------------------------------------------------------- 1 | <%- if controller_name != 'sessions' %> 2 | <%= link_to "Log in", new_session_path(resource_name), class: 'text-stone-500' %>
3 | <% end %> 4 | 5 | <%- if devise_mapping.registerable? && controller_name != 'registrations' %> 6 | <%= link_to "Sign up", new_registration_path(resource_name), class: 'text-stone-500' %>
7 | <% end %> 8 | 9 | <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> 10 | <%= link_to "Forgot your password?", new_password_path(resource_name), class: 'text-stone-500' %>
11 | <% end %> 12 | 13 | <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> 14 | <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name), class: 'text-stone-500' %>
15 | <% end %> 16 | 17 | <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> 18 | <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name), class: 'text-stone-500' %>
19 | <% end %> 20 | 21 | <%- if devise_mapping.omniauthable? %> 22 | <%- resource_class.omniauth_providers.each do |provider| %> 23 | <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), method: :post %>
24 | <% end %> 25 | <% end %> 26 | -------------------------------------------------------------------------------- /app/views/devise/sessions/new.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> 2 |
3 | <%= link_to root_path, class: "flex items-center justify-center p-2" do %> 4 | 5 | <% end %> 6 |

LOGIN

7 | <%= f.submit "Log in" %> 8 |
9 |
10 |
11 |

<%= notice %>

12 |

<%= alert %>

13 |
14 |
15 | <%= f.email_field :email, autofocus: true, placeholder: "Email", autocomplete: "email", class: 'input-field' %> 16 |
17 | 18 |
19 | <%= f.password_field :password, placeholder:"Password", autocomplete: "current-password", class: 'input-field' %> 20 |
21 |
22 | <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> 23 | <%= link_to "Forgot password?", new_password_path(resource_name), class: 'text-stone-500' %>
24 | <% end %> 25 | <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> 26 | <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name), class: 'text-stone-500' %>
27 | <% end %> 28 |
29 | <% end %> 30 | 31 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.tailwind.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | @import url('https://fonts.googleapis.com/css2?family=Lobster+Two:ital,wght@0,400;0,700;1,400;1,700&display=swap'); 6 | @import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); 7 | 8 | @layer base { 9 | .logo { 10 | font-family: 'Lobster Two', cursive; 11 | } 12 | 13 | form .field { 14 | @apply mb-2 px-4 w-full; 15 | } 16 | 17 | nav { 18 | @apply bg-solid-blue text-white; 19 | } 20 | } 21 | 22 | @layer components { 23 | .auth-header { 24 | @apply flex bg-solid-blue text-white justify-between items-center px-2 sm:px-4 py-2.5; 25 | } 26 | 27 | .btn { 28 | @apply py-2 px-4 rounded font-normal text-center uppercase; 29 | } 30 | 31 | .btn-primary { 32 | @apply bg-solid-blue text-white; 33 | } 34 | 35 | .input-field { 36 | outline: none; 37 | width: 100%; 38 | height: 40px; 39 | border: 1px solid lightgray; 40 | border-top: none; 41 | padding: 10px; 42 | } 43 | 44 | .action { 45 | @apply w-screen p-4 bg-solid-green fixed bottom-0 left-0; 46 | } 47 | 48 | .action button, 49 | .action a { 50 | @apply py-3 uppercase flex justify-center rounded border-2 border-white border-solid text-white text-base; 51 | } 52 | 53 | .input-submit { 54 | @apply py-3 uppercase w-full flex justify-center rounded border-2 border-white border-solid text-white text-base; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /spec/requests/spends_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | # This spec was generated by rspec-rails when you ran the scaffold generator. 4 | # It demonstrates how one might use RSpec to test the controller code that 5 | # was generated by Rails when you ran the scaffold generator. 6 | # 7 | # It assumes that the implementation code is generated by the rails scaffold 8 | # generator. If you are using any extension libraries to generate different 9 | # controller code, this generated spec may or may not pass. 10 | # 11 | # It only uses APIs available in rails and/or rspec-rails. There are a number 12 | # of tools you can use to make these specs even more expressive, but we're 13 | # sticking to rails and rspec-rails APIs to keep things simple and stable. 14 | 15 | RSpec.describe '/spends', type: :request do 16 | before :each do 17 | @user = User.create(name: 'Samantha Woods', email: 'sam@outlook.com', password: 'password', 18 | password_confirmation: 'password') 19 | @group = Group.create(name: 'Pets', icon: 'pet_img', user: @user) 20 | @spend = Spend.create(name: 'Food', amount: 20, author: @user) 21 | @spend.groups << @group 22 | sign_in @user 23 | end 24 | 25 | describe 'GET /index' do 26 | it 'returns http success' do 27 | get group_spends_path(@group) 28 | expect(response).to have_http_status(302) 29 | end 30 | end 31 | 32 | describe 'GET /show' do 33 | it 'returns http success' do 34 | get group_spends_path(@group, @spend) 35 | expect(response).to have_http_status(302) 36 | end 37 | end 38 | 39 | describe 'GET /new' do 40 | it 'renders a successful response' do 41 | get new_group_spend_path(@group) 42 | expect(response).to have_http_status(302) 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /spec/requests/groups_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | # This spec was generated by rspec-rails when you ran the scaffold generator. 4 | # It demonstrates how one might use RSpec to test the controller code that 5 | # was generated by Rails when you ran the scaffold generator. 6 | # 7 | # It assumes that the implementation code is generated by the rails scaffold 8 | # generator. If you are using any extension libraries to generate different 9 | # controller code, this generated spec may or may not pass. 10 | # 11 | # It only uses APIs available in rails and/or rspec-rails. There are a number 12 | # of tools you can use to make these specs even more expressive, but we're 13 | # sticking to rails and rspec-rails APIs to keep things simple and stable. 14 | 15 | RSpec.describe '/groups', type: :request do 16 | # This should return the minimal set of attributes required to create a valid 17 | # Group. As you add validations to Group, be sure to 18 | # adjust the attributes here as well. 19 | before do 20 | @user = User.create(name: 'Samantha Woods', email: 'sam@outlook.com', password: 'password', 21 | password_confirmation: 'password') 22 | @group = Group.create(name: 'Pets', icon: 'pet_img', user: @user) 23 | sign_in @user 24 | end 25 | describe 'GET /index' do 26 | it 'returns http success' do 27 | get groups_path 28 | expect(response).to have_http_status(302) 29 | end 30 | end 31 | 32 | describe 'GET /show' do 33 | it 'returns http success' do 34 | get group_path(@group.id) 35 | expect(response).to have_http_status(302) 36 | end 37 | end 38 | 39 | describe 'GET /new' do 40 | it 'renders a successful response' do 41 | get new_group_path 42 | expect(response).to have_http_status(302) 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /.github/workflows/linters.yml: -------------------------------------------------------------------------------- 1 | name: Linters 2 | 3 | on: pull_request 4 | 5 | env: 6 | FORCE_COLOR: 1 7 | 8 | jobs: 9 | rubocop: 10 | name: Rubocop 11 | runs-on: ubuntu-22.04 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: actions/setup-ruby@v1 15 | with: 16 | ruby-version: 3.1.x 17 | - name: Setup Rubocop 18 | run: | 19 | gem install --no-document rubocop -v '>= 1.0, < 2.0' # https://docs.rubocop.org/en/stable/installation/ 20 | [ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.rubocop.yml 21 | - name: Rubocop Report 22 | run: rubocop --color 23 | stylelint: 24 | name: Stylelint 25 | runs-on: ubuntu-22.04 26 | steps: 27 | - uses: actions/checkout@v2 28 | - uses: actions/setup-node@v1 29 | with: 30 | node-version: "12.x" 31 | - name: Setup Stylelint 32 | run: | 33 | npm install --save-dev stylelint@13.x stylelint-scss@3.x stylelint-config-standard@21.x stylelint-csstree-validator@1.x 34 | [ -f .stylelintrc.json ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ror/.stylelintrc.json 35 | - name: Stylelint Report 36 | run: npx stylelint "**/*.{css,scss}" 37 | nodechecker: 38 | name: node_modules checker 39 | runs-on: ubuntu-22.04 40 | steps: 41 | - uses: actions/checkout@v2 42 | - name: Check node_modules existence 43 | run: | 44 | if [ -d "node_modules/" ]; then echo -e "\e[1;31mThe node_modules/ folder was pushed to the repo. Please remove it from the GitHub repository and try again."; echo -e "\e[1;32mYou can set up a .gitignore file with this folder included on it to prevent this from happening in the future." && exit 1; fi -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /db/migrate/20221121225119_add_devise_columns_to_user.rb: -------------------------------------------------------------------------------- 1 | class AddDeviseColumnsToUser < ActiveRecord::Migration[7.0] 2 | def self.up 3 | change_table :users do |t| 4 | ## Database authenticatable 5 | t.string :email, null: false, default: "" 6 | t.string :encrypted_password, null: false, default: "" 7 | 8 | ## Recoverable 9 | t.string :reset_password_token 10 | t.datetime :reset_password_sent_at 11 | 12 | ## Rememberable 13 | t.datetime :remember_created_at 14 | 15 | ## Trackable 16 | # t.integer :sign_in_count, default: 0, null: false 17 | # t.datetime :current_sign_in_at 18 | # t.datetime :last_sign_in_at 19 | # t.string :current_sign_in_ip 20 | # t.string :last_sign_in_ip 21 | 22 | ## Confirmable 23 | t.string :confirmation_token 24 | t.datetime :confirmed_at 25 | t.datetime :confirmation_sent_at 26 | t.string :unconfirmed_email # Only if using reconfirmable 27 | 28 | ## Lockable 29 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts 30 | # t.string :unlock_token # Only if unlock strategy is :email or :both 31 | # t.datetime :locked_at 32 | 33 | 34 | # Uncomment below if timestamps were not included in your original model. 35 | # t.timestamps null: false 36 | end 37 | 38 | add_index :users, :email, unique: true 39 | add_index :users, :reset_password_token, unique: true 40 | add_index :users, :confirmation_token, unique: true 41 | # add_index :users, :unlock_token, unique: true 42 | end 43 | 44 | def self.down 45 | # By default, we don't want to make any assumption about how to roll back a migration when your 46 | # model already existed. Please edit below which fields you would like to remove in this migration. 47 | raise ActiveRecord::IrreversibleMigration 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Puma can serve each request in a thread from an internal thread pool. 4 | # The `threads` method setting takes two numbers: a minimum and maximum. 5 | # Any libraries that use thread pools should be configured to match 6 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 7 | # and maximum; this matches the default thread size of Active Record. 8 | # 9 | max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5) 10 | min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count } 11 | threads min_threads_count, max_threads_count 12 | 13 | # Specifies the `worker_timeout` threshold that Puma will use to wait before 14 | # terminating a worker in development environments. 15 | # 16 | worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development' 17 | 18 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 19 | # 20 | port ENV.fetch('PORT', 3000) 21 | 22 | # Specifies the `environment` that Puma will run in. 23 | # 24 | environment ENV.fetch('RAILS_ENV', 'development') 25 | 26 | # Specifies the `pidfile` that Puma will use. 27 | pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid') 28 | 29 | # Specifies the number of `workers` to boot in clustered mode. 30 | # Workers are forked web server processes. If using threads and workers together 31 | # the concurrency of the application would be max `threads` * `workers`. 32 | # Workers do not work on JRuby or Windows (both of which do not support 33 | # processes). 34 | # 35 | workers ENV.fetch("WEB_CONCURRENCY") { 4 } 36 | 37 | # Use the `preload_app!` method when specifying a `workers` number. 38 | # This directive tells Puma to first boot the application and load code 39 | # before forking the application. This takes advantage of Copy On Write 40 | # process behavior so workers use less memory. 41 | # 42 | preload_app! 43 | 44 | # Allow puma to be restarted by `bin/rails restart` command. 45 | plugin :tmp_restart 46 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /app/views/devise/registrations/edit.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> 2 |
3 | <%= link_to :back, class: "flex items-center justify-center p-2" do %> 4 | 5 | <% end %> 6 |

Edit <%= resource_name.to_s.humanize %>

7 | <%= f.submit "Update" %> 8 |
9 |
10 | <%= render "devise/shared/error_messages", resource: resource %> 11 | 12 |
13 | <%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: "Email", class: 'input-field' %> 14 |
15 | 16 | <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> 17 |
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
18 | <% end %> 19 | 20 |
21 | <%= f.label :password %> (leave blank if you don't want to change it)
22 | <%= f.password_field :password, autocomplete: "new-password", placeholder: "New Password", class: 'input-field' %> 23 | <% if @minimum_password_length %> 24 |
25 | <%= @minimum_password_length %> characters minimum 26 | <% end %> 27 |
28 | 29 |
30 | <%= f.label :password_confirmation %>
31 | <%= f.password_field :password_confirmation, autocomplete: "new-password", placeholder: "New password", class: 'input-field' %> 32 |
33 | 34 |
35 | <%= f.label :current_password %> (we need your current password to confirm your changes)
36 | <%= f.password_field :current_password, autocomplete: "current-password", placeholder: "Current password", class: 'input-field' %> 37 |
38 | 39 |
40 | 41 |
42 | <% end %> 43 | 44 |

Cancel my account

45 | 46 |

Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>

47 | 48 | -------------------------------------------------------------------------------- /app/controllers/users_controller.rb: -------------------------------------------------------------------------------- 1 | class UsersController < ApplicationController 2 | before_action :set_user, only: %i[show edit update destroy] 3 | 4 | # GET /users or /users.json 5 | def index 6 | @users = User.all 7 | end 8 | 9 | # GET /users/1 or /users/1.json 10 | def show; end 11 | 12 | # GET /users/new 13 | def new 14 | @user = User.new 15 | end 16 | 17 | # GET /users/1/edit 18 | def edit; end 19 | 20 | # POST /users or /users.json 21 | def create 22 | @user = User.new(user_params) 23 | 24 | respond_to do |format| 25 | if @user.save 26 | format.html { redirect_to user_url(@user), notice: 'User was successfully created.' } 27 | format.json { render :show, status: :created, location: @user } 28 | else 29 | format.html { render :new, status: :unprocessable_entity } 30 | format.json { render json: @user.errors, status: :unprocessable_entity } 31 | end 32 | end 33 | end 34 | 35 | # PATCH/PUT /users/1 or /users/1.json 36 | def update 37 | respond_to do |format| 38 | if @user.update(user_params) 39 | format.html { redirect_to user_url(@user), notice: 'User was successfully updated.' } 40 | format.json { render :show, status: :ok, location: @user } 41 | else 42 | format.html { render :edit, status: :unprocessable_entity } 43 | format.json { render json: @user.errors, status: :unprocessable_entity } 44 | end 45 | end 46 | end 47 | 48 | # DELETE /users/1 or /users/1.json 49 | def destroy 50 | @user.destroy 51 | 52 | respond_to do |format| 53 | format.html { redirect_to users_url, notice: 'User was successfully destroyed.' } 54 | format.json { head :no_content } 55 | end 56 | end 57 | 58 | private 59 | 60 | # Use callbacks to share common setup or constraints between actions. 61 | def set_user 62 | @user = User.find(params[:id]) 63 | end 64 | 65 | # Only allow a list of trusted parameters through. 66 | def user_params 67 | params.require(:user).permit(:name) 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /app/controllers/groups_controller.rb: -------------------------------------------------------------------------------- 1 | class GroupsController < ApplicationController 2 | before_action :set_group, only: %i[show edit update destroy] 3 | 4 | # GET /groups or /groups.json 5 | def index 6 | @groups = current_user.groups.order(created_at: :desc) 7 | @title = 'Categories' 8 | end 9 | 10 | # GET /groups/1 or /groups/1.json 11 | def show; end 12 | 13 | # GET /groups/new 14 | def new 15 | @group = Group.new 16 | @title = 'New category' 17 | end 18 | 19 | # GET /groups/1/edit 20 | def edit; end 21 | 22 | # POST /groups or /groups.json 23 | def create 24 | @group = Group.new(group_params) 25 | @group.user = current_user 26 | respond_to do |format| 27 | if @group.save 28 | format.html { redirect_to groups_path, notice: "Category #{@group.name} was successfully created." } 29 | format.json { render :show, status: :created, location: @group } 30 | else 31 | format.html { render :new, status: :unprocessable_entity } 32 | format.json { render json: @group.errors, status: :unprocessable_entity } 33 | end 34 | end 35 | end 36 | 37 | # PATCH/PUT /groups/1 or /groups/1.json 38 | def update 39 | respond_to do |format| 40 | if @group.update(group_params) 41 | format.html { redirect_to group_url(@group), notice: 'Group was successfully updated.' } 42 | format.json { render :show, status: :ok, location: @group } 43 | else 44 | format.html { render :edit, status: :unprocessable_entity } 45 | format.json { render json: @group.errors, status: :unprocessable_entity } 46 | end 47 | end 48 | end 49 | 50 | # DELETE /groups/1 or /groups/1.json 51 | def destroy 52 | @group.destroy 53 | 54 | respond_to do |format| 55 | format.html { redirect_to groups_url, notice: 'Group was successfully destroyed.' } 56 | format.json { head :no_content } 57 | end 58 | end 59 | 60 | private 61 | 62 | # Use callbacks to share common setup or constraints between actions. 63 | def set_group 64 | @group = Group.find(params[:id]) 65 | end 66 | 67 | # Only allow a list of trusted parameters through. 68 | def group_params 69 | params.require(:group).permit(:icon, :name) 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /app/controllers/spends_controller.rb: -------------------------------------------------------------------------------- 1 | class SpendsController < ApplicationController 2 | before_action :set_spend, only: %i[show edit update destroy] 3 | before_action :set_group, only: %i[index new] 4 | 5 | # GET /spends or /spends.json 6 | def index 7 | @spends = @group.spends.order(created_at: :desc) 8 | @title = @group.name 9 | end 10 | 11 | # GET /spends/1 or /spends/1.json 12 | def show; end 13 | 14 | # GET /spends/new 15 | def new 16 | @spend = Spend.new 17 | @title = 'New Transaction' 18 | @spend.groups << @group 19 | @groups = current_user.groups 20 | end 21 | 22 | # GET /spends/1/edit 23 | def edit; end 24 | 25 | # POST /spends or /spends.json 26 | def create 27 | @spend = Spend.new(spend_params) 28 | @spend.author = current_user 29 | respond_to do |format| 30 | if @spend.save 31 | format.html { redirect_to group_spends_path, notice: "Transaction #{@spend.name} was successfully created." } 32 | format.json { render :show, status: :created, location: @spend } 33 | else 34 | @group = Group.find(params[:group_id]) 35 | @groups = current_user.groups 36 | format.html { render :new, status: :unprocessable_entity } 37 | format.json { render json: @spend.errors, status: :unprocessable_entity } 38 | end 39 | end 40 | end 41 | 42 | # PATCH/PUT /spends/1 or /spends/1.json 43 | def update 44 | respond_to do |format| 45 | if @spend.update(spend_params) 46 | format.html { redirect_to spend_url(@spend), notice: 'Spend was successfully updated.' } 47 | format.json { render :show, status: :ok, location: @spend } 48 | else 49 | format.html { render :edit, status: :unprocessable_entity } 50 | format.json { render json: @spend.errors, status: :unprocessable_entity } 51 | end 52 | end 53 | end 54 | 55 | # DELETE /spends/1 or /spends/1.json 56 | def destroy 57 | @spend.destroy 58 | 59 | respond_to do |format| 60 | format.html { redirect_to spends_url, notice: 'Spend was successfully destroyed.' } 61 | format.json { head :no_content } 62 | end 63 | end 64 | 65 | private 66 | 67 | # Use callbacks to share common setup or constraints between actions. 68 | def set_spend 69 | @spend = Spend.find(params[:id]) 70 | end 71 | 72 | def set_group 73 | @group = Group.find(params[:group_id]) 74 | end 75 | 76 | # Only allow a list of trusted parameters through. 77 | def spend_params 78 | params.require(:spend).permit(:name, :amount, group_ids: []) 79 | end 80 | end 81 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # This file is the source Rails uses to define your schema when running `bin/rails 6 | # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to 7 | # be faster and is potentially less error prone than running all of your 8 | # migrations from scratch. Old migrations may fail to apply correctly if those 9 | # migrations use external dependencies or application code. 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema[7.0].define(version: 2022_11_21_225119) do 14 | # These are extensions that must be enabled in order to support this database 15 | enable_extension "plpgsql" 16 | 17 | create_table "groups", force: :cascade do |t| 18 | t.string "icon" 19 | t.string "name" 20 | t.datetime "created_at", null: false 21 | t.datetime "updated_at", null: false 22 | t.bigint "user_id", null: false 23 | t.index ["user_id"], name: "index_groups_on_user_id" 24 | end 25 | 26 | create_table "groups_spends", id: false, force: :cascade do |t| 27 | t.bigint "group_id", null: false 28 | t.bigint "spend_id", null: false 29 | end 30 | 31 | create_table "spends", force: :cascade do |t| 32 | t.string "name" 33 | t.decimal "amount", default: "0.0" 34 | t.datetime "created_at", null: false 35 | t.datetime "updated_at", null: false 36 | t.bigint "author_id", null: false 37 | t.index ["author_id"], name: "index_spends_on_author_id" 38 | end 39 | 40 | create_table "users", force: :cascade do |t| 41 | t.string "name" 42 | t.datetime "created_at", null: false 43 | t.datetime "updated_at", null: false 44 | t.string "email", default: "", null: false 45 | t.string "encrypted_password", default: "", null: false 46 | t.string "reset_password_token" 47 | t.datetime "reset_password_sent_at" 48 | t.datetime "remember_created_at" 49 | t.string "confirmation_token" 50 | t.datetime "confirmed_at" 51 | t.datetime "confirmation_sent_at" 52 | t.string "unconfirmed_email" 53 | t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true 54 | t.index ["email"], name: "index_users_on_email", unique: true 55 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 56 | end 57 | 58 | add_foreign_key "groups", "users" 59 | add_foreign_key "spends", "users", column: "author_id" 60 | end 61 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'active_support/core_ext/integer/time' 4 | 5 | # The test environment is used exclusively to run your application's 6 | # test suite. You never need to work with it otherwise. Remember that 7 | # your test database is "scratch space" for the test suite and is wiped 8 | # and recreated between test runs. Don't rely on the data there! 9 | 10 | Rails.application.configure do 11 | # Settings specified here will take precedence over those in config/application.rb. 12 | 13 | # Turn false under Spring and add config.action_view.cache_template_loading = true. 14 | config.cache_classes = true 15 | 16 | # Eager loading loads your whole application. When running a single test locally, 17 | # this probably isn't necessary. It's a good idea to do in a continuous integration 18 | # system, or in some way before deploying your code. 19 | config.eager_load = ENV['CI'].present? 20 | 21 | # Configure public file server for tests with Cache-Control for performance. 22 | config.public_file_server.enabled = true 23 | config.public_file_server.headers = { 24 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 25 | } 26 | 27 | # Show full error reports and disable caching. 28 | config.consider_all_requests_local = true 29 | config.action_controller.perform_caching = false 30 | config.cache_store = :null_store 31 | 32 | # Raise exceptions instead of rendering exception templates. 33 | config.action_dispatch.show_exceptions = false 34 | 35 | # Disable request forgery protection in test environment. 36 | config.action_controller.allow_forgery_protection = false 37 | 38 | # Store uploaded files on the local file system in a temporary directory. 39 | config.active_storage.service = :test 40 | 41 | config.action_mailer.perform_caching = false 42 | 43 | # Tell Action Mailer not to deliver emails to the real world. 44 | # The :test delivery method accumulates sent emails in the 45 | # ActionMailer::Base.deliveries array. 46 | config.action_mailer.delivery_method = :test 47 | 48 | # Print deprecation notices to the stderr. 49 | config.active_support.deprecation = :stderr 50 | 51 | # Raise exceptions for disallowed deprecations. 52 | config.active_support.disallowed_deprecation = :raise 53 | 54 | # Tell Active Support which deprecation messages to disallow. 55 | config.active_support.disallowed_deprecation_warnings = [] 56 | 57 | # Raises error for missing translations. 58 | # config.i18n.raise_on_missing_translations = true 59 | 60 | # Annotate rendered view with file names. 61 | # config.action_view.annotate_rendered_view_with_filenames = true 62 | config.action_mailer.default_url_options = { host: "localhost", port: 3000 } 63 | end 64 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby '3.1.2' 5 | 6 | # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" 7 | gem 'rails', '~> 7.0.4' 8 | 9 | # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] 10 | gem 'sprockets-rails' 11 | 12 | # Use the devise gem as the session and account manager for the application 13 | gem 'devise' 14 | 15 | # Use postgresql as the database for Active Record 16 | gem 'pg', '~> 1.1' 17 | 18 | # Use the Puma web server [https://github.com/puma/puma] 19 | gem 'puma', '~> 5.0' 20 | 21 | # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] 22 | gem 'importmap-rails' 23 | 24 | # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] 25 | gem 'turbo-rails' 26 | 27 | # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] 28 | gem 'stimulus-rails' 29 | 30 | # Build JSON APIs with ease [https://github.com/rails/jbuilder] 31 | gem 'jbuilder' 32 | 33 | # Use for faking data 34 | gem 'faker' 35 | 36 | # Use Redis adapter to run Action Cable in production 37 | # gem "redis", "~> 4.0" 38 | 39 | # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] 40 | # gem "kredis" 41 | 42 | # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] 43 | # gem "bcrypt", "~> 3.1.7" 44 | 45 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 46 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] 47 | 48 | # Reduces boot times through caching; required in config/boot.rb 49 | gem 'bootsnap', require: false 50 | 51 | # Use Sass to process CSS 52 | # gem "sassc-rails" 53 | 54 | # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] 55 | # gem "image_processing", "~> 1.2" 56 | 57 | # Use to automatically loads environment variables from a .env file into the process.env object 58 | gem 'dotenv-rails' 59 | 60 | # Use for restricting what resources a given user is allowed to access 61 | gem 'cancancan' 62 | 63 | group :development, :test do 64 | # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem 65 | gem 'database_cleaner' 66 | gem 'debug', platforms: %i[mri mingw x64_mingw] 67 | gem 'ffi' 68 | gem 'rails-controller-testing' 69 | gem 'rspec-rails' 70 | end 71 | 72 | group :development do 73 | # Use console on exceptions pages [https://github.com/rails/web-console] 74 | gem 'web-console' 75 | # Bullet for check N+1 problems 76 | gem 'bullet', require: true 77 | # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] 78 | # gem "rack-mini-profiler" 79 | 80 | # Speed up commands on slow machines / big apps [https://github.com/rails/spring] 81 | # gem "spring" 82 | # gem "spring" 83 | end 84 | 85 | group :test do 86 | # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] 87 | gem 'capybara' 88 | gem 'selenium-webdriver' 89 | gem 'webdrivers' 90 | end 91 | 92 | gem 'tailwindcss-rails', '~> 2.0' 93 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'active_support/core_ext/integer/time' 4 | 5 | Rails.application.configure do 6 | config.after_initialize do 7 | Bullet.enable = true 8 | Bullet.alert = true 9 | Bullet.bullet_logger = true 10 | Bullet.console = true 11 | Bullet.rails_logger = true 12 | Bullet.add_footer = true 13 | end 14 | 15 | # Settings specified here will take precedence over those in config/application.rb. 16 | 17 | # In the development environment your application's code is reloaded any time 18 | # it changes. This slows down response time but is perfect for development 19 | # since you don't have to restart the web server when you make code changes. 20 | config.cache_classes = false 21 | 22 | # Do not eager load code on boot. 23 | config.eager_load = false 24 | 25 | # Show full error reports. 26 | config.consider_all_requests_local = true 27 | 28 | # Enable server timing 29 | config.server_timing = true 30 | 31 | # Enable/disable caching. By default caching is disabled. 32 | # Run rails dev:cache to toggle caching. 33 | if Rails.root.join('tmp/caching-dev.txt').exist? 34 | config.action_controller.perform_caching = true 35 | config.action_controller.enable_fragment_cache_logging = true 36 | 37 | config.cache_store = :memory_store 38 | config.public_file_server.headers = { 39 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 40 | } 41 | else 42 | config.action_controller.perform_caching = false 43 | 44 | config.cache_store = :null_store 45 | end 46 | 47 | # Store uploaded files on the local file system (see config/storage.yml for options). 48 | config.active_storage.service = :local 49 | 50 | # Don't care if the mailer can't send. 51 | config.action_mailer.raise_delivery_errors = false 52 | 53 | config.action_mailer.perform_caching = false 54 | 55 | # config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } 56 | 57 | # config.action_mailer.delivery_method = :letter_opener 58 | 59 | # config.action_mailer.perform_deliveries = true 60 | 61 | # Print deprecation notices to the Rails logger. 62 | config.active_support.deprecation = :log 63 | 64 | # Raise exceptions for disallowed deprecations. 65 | config.active_support.disallowed_deprecation = :raise 66 | 67 | # Tell Active Support which deprecation messages to disallow. 68 | config.active_support.disallowed_deprecation_warnings = [] 69 | 70 | # Raise an error on page load if there are pending migrations. 71 | config.active_record.migration_error = :page_load 72 | 73 | # Highlight code that triggered database queries in logs. 74 | config.active_record.verbose_query_logs = true 75 | 76 | # Suppress logger output for asset requests. 77 | config.assets.quiet = true 78 | 79 | # Raises error for missing translations. 80 | # config.i18n.raise_on_missing_translations = true 81 | 82 | # Annotate rendered view with file names. 83 | # config.action_view.annotate_rendered_view_with_filenames = true 84 | 85 | # Uncomment if you wish to allow Action Cable access from any origin. 86 | # config.action_cable.disable_request_forgery_protection = true 87 | end 88 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | require 'spec_helper' 3 | require 'capybara/rspec' 4 | ENV['RAILS_ENV'] ||= 'test' 5 | require_relative '../config/environment' 6 | # Prevent database truncation if the environment is production 7 | abort('The Rails environment is running in production mode!') if Rails.env.production? 8 | require 'rspec/rails' 9 | # Add additional requires below this line. Rails is not loaded until this point! 10 | 11 | # Requires supporting ruby files with custom matchers and macros, etc, in 12 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 13 | # run as spec files by default. This means that files in spec/support that end 14 | # in _spec.rb will both be required and run as specs, causing the specs to be 15 | # run twice. It is recommended that you do not name files matching this glob to 16 | # end with _spec.rb. You can configure this pattern with the --pattern 17 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 18 | # 19 | # The following line is provided for convenience purposes. It has the downside 20 | # of increasing the boot-up time by auto-requiring all files in the support 21 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 22 | # require only the support files necessary. 23 | # 24 | # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } 25 | 26 | # Checks for pending migrations and applies them before tests are run. 27 | # If you are not using ActiveRecord, you can remove these lines. 28 | begin 29 | ActiveRecord::Migration.maintain_test_schema! 30 | rescue ActiveRecord::PendingMigrationError => e 31 | abort e.to_s.strip 32 | end 33 | RSpec.configure do |config| 34 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 35 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 36 | 37 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 38 | # examples within a transaction, remove the following line or assign false 39 | # instead of true. 40 | config.use_transactional_fixtures = true 41 | 42 | # You can uncomment this line to turn off ActiveRecord support entirely. 43 | # config.use_active_record = false 44 | 45 | # RSpec Rails can automatically mix in different behaviours to your tests 46 | # based on their file location, for example enabling you to call `get` and 47 | # `post` in specs under `spec/controllers`. 48 | # 49 | # You can disable this behaviour by removing the line below, and instead 50 | # explicitly tag your specs with their type, e.g.: 51 | # 52 | # RSpec.describe UsersController, type: :controller do 53 | # # ... 54 | # end 55 | # 56 | # The different available types are documented in the features, such as in 57 | # https://relishapp.com/rspec/rspec-rails/docs 58 | config.infer_spec_type_from_file_location! 59 | 60 | # Filter lines from Rails gems in backtraces. 61 | config.filter_rails_from_backtrace! 62 | # arbitrary gems may also be filtered via: 63 | # config.filter_gems_from_backtrace("gem name") 64 | config.include Devise::Test::IntegrationHelpers, type: :feature 65 | config.include Devise::Test::IntegrationHelpers, type: :request 66 | end 67 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 9.3 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On macOS with Homebrew: 6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7 | # On macOS with MacPorts: 8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 9 | # On Windows: 10 | # gem install pg 11 | # Choose the win32 build. 12 | # Install PostgreSQL and put its /bin directory on your path. 13 | # 14 | # Configure Using Gemfile 15 | # gem "pg" 16 | # 17 | default: &default 18 | adapter: postgresql 19 | encoding: unicode 20 | # For details on connection pooling, see Rails configuration guide 21 | # https://guides.rubyonrails.org/configuring.html#database-pooling 22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 23 | host: <%= ENV['POSTGRES_HOST'] %> 24 | username: <%= POSTGRES_USER='postgres' %> 25 | password: <%= POSTGRES_PASSWORD='12345' %> 26 | port: 5432 27 | 28 | development: 29 | <<: *default 30 | database: money_moves_development 31 | 32 | # The specified database role being used to connect to postgres. 33 | # To create additional roles in postgres see `$ createuser --help`. 34 | # When left blank, postgres will use the default role. This is 35 | # the same name as the operating system user running Rails. 36 | #username: newProject 37 | 38 | # The password associated with the postgres role (username). 39 | #password: 40 | 41 | # Connect on a TCP socket. Omitted by default since the client uses a 42 | # domain socket that doesn't need configuration. Windows does not have 43 | # domain sockets, so uncomment these lines. 44 | #host: localhost 45 | 46 | # The TCP port the server listens on. Defaults to 5432. 47 | # If your server runs on a different port number, change accordingly. 48 | #port: 5432 49 | 50 | # Schema search path. The server defaults to $user,public 51 | #schema_search_path: myapp,sharedapp,public 52 | 53 | # Minimum log levels, in increasing order: 54 | # debug5, debug4, debug3, debug2, debug1, 55 | # log, notice, warning, error, fatal, and panic 56 | # Defaults to warning. 57 | #min_messages: notice 58 | 59 | # Warning: The database defined as "test" will be erased and 60 | # re-generated from your development database when you run "rake". 61 | # Do not set this db to the same as development or production. 62 | test: 63 | <<: *default 64 | database: money_moves_test 65 | 66 | # As with config/credentials.yml, you never want to store sensitive information, 67 | # like your database password, in your source code. If your source code is 68 | # ever seen by anyone, they now have access to your database. 69 | # 70 | # Instead, provide the password or a full connection URL as an environment 71 | # variable when you boot the app. For example: 72 | # 73 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 74 | # 75 | # If the connection URL is provided in the special DATABASE_URL environment 76 | # variable, Rails will automatically merge its configuration values on top of 77 | # the values provided in this file. Alternatively, you can specify a connection 78 | # URL environment variable explicitly: 79 | # 80 | # production: 81 | # url: <%= ENV["MY_APP_DATABASE_URL"] %> 82 | # 83 | # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database 84 | # for a full overview on how database connection configuration can be specified. 85 | # 86 | production: 87 | <<: *default 88 | url: <%= ENV['DATABASE_URL'] %> 89 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'bundle' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require 'rubygems' 12 | 13 | m = Module.new do 14 | module_function 15 | 16 | def invoked_as_script? 17 | File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__) 18 | end 19 | 20 | def env_var_version 21 | ENV['BUNDLER_VERSION'] 22 | end 23 | 24 | def cli_arg_version 25 | return unless invoked_as_script? # don't want to hijack other binstubs 26 | return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update` 27 | 28 | bundler_version = nil 29 | update_index = nil 30 | ARGV.each_with_index do |a, i| 31 | bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN 32 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 33 | 34 | bundler_version = Regexp.last_match(1) 35 | update_index = i 36 | end 37 | bundler_version 38 | end 39 | 40 | def gemfile 41 | gemfile = ENV['BUNDLE_GEMFILE'] 42 | return gemfile if gemfile && !gemfile.empty? 43 | 44 | File.expand_path('../Gemfile', __dir__) 45 | end 46 | 47 | def lockfile 48 | lockfile = 49 | case File.basename(gemfile) 50 | when 'gems.rb' then gemfile.sub(/\.rb$/, gemfile) 51 | else "#{gemfile}.lock" 52 | end 53 | File.expand_path(lockfile) 54 | end 55 | 56 | def lockfile_version 57 | return unless File.file?(lockfile) 58 | 59 | lockfile_contents = File.read(lockfile) 60 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 61 | 62 | Regexp.last_match(1) 63 | end 64 | 65 | def bundler_requirement 66 | @bundler_requirement ||= 67 | env_var_version || cli_arg_version || 68 | bundler_requirement_for(lockfile_version) 69 | end 70 | 71 | def bundler_requirement_for(version) 72 | return "#{Gem::Requirement.default}.a" unless version 73 | 74 | bundler_gem_version = Gem::Version.new(version) 75 | 76 | requirement = bundler_gem_version.approximate_recommendation 77 | 78 | return requirement unless Gem.rubygems_version < Gem::Version.new('2.7.0') 79 | 80 | requirement += '.a' if bundler_gem_version.prerelease? 81 | 82 | requirement 83 | end 84 | 85 | def load_bundler! 86 | ENV['BUNDLE_GEMFILE'] ||= gemfile 87 | 88 | activate_bundler 89 | end 90 | 91 | def activate_bundler 92 | gem_error = activation_error_handling do 93 | gem 'bundler', bundler_requirement 94 | end 95 | return if gem_error.nil? 96 | 97 | require_error = activation_error_handling do 98 | require 'bundler/version' 99 | end 100 | if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) 101 | return 102 | end 103 | 104 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" 105 | exit 42 106 | end 107 | 108 | def activation_error_handling 109 | yield 110 | nil 111 | rescue StandardError, LoadError => e 112 | e 113 | end 114 | end 115 | 116 | m.load_bundler! 117 | 118 | load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script? 119 | -------------------------------------------------------------------------------- /bin/bundle.cmd: -------------------------------------------------------------------------------- 1 | @ruby -x "%~f0" %* 2 | @exit /b %ERRORLEVEL% 3 | 4 | #!/usr/bin/env ruby 5 | # frozen_string_literal: true 6 | 7 | # 8 | # This file was generated by Bundler. 9 | # 10 | # The application 'bundle' is installed as part of a gem, and 11 | # this file is here to facilitate running it. 12 | # 13 | 14 | require "rubygems" 15 | 16 | m = Module.new do 17 | module_function 18 | 19 | def invoked_as_script? 20 | File.expand_path($0) == File.expand_path(__FILE__) 21 | end 22 | 23 | def env_var_version 24 | ENV["BUNDLER_VERSION"] 25 | end 26 | 27 | def cli_arg_version 28 | return unless invoked_as_script? # don't want to hijack other binstubs 29 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` 30 | bundler_version = nil 31 | update_index = nil 32 | ARGV.each_with_index do |a, i| 33 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN 34 | bundler_version = a 35 | end 36 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 37 | bundler_version = $1 38 | update_index = i 39 | end 40 | bundler_version 41 | end 42 | 43 | def gemfile 44 | gemfile = ENV["BUNDLE_GEMFILE"] 45 | return gemfile if gemfile && !gemfile.empty? 46 | 47 | File.expand_path("../Gemfile", __dir__) 48 | end 49 | 50 | def lockfile 51 | lockfile = 52 | case File.basename(gemfile) 53 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) 54 | else "#{gemfile}.lock" 55 | end 56 | File.expand_path(lockfile) 57 | end 58 | 59 | def lockfile_version 60 | return unless File.file?(lockfile) 61 | lockfile_contents = File.read(lockfile) 62 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 63 | Regexp.last_match(1) 64 | end 65 | 66 | def bundler_requirement 67 | @bundler_requirement ||= 68 | env_var_version || cli_arg_version || 69 | bundler_requirement_for(lockfile_version) 70 | end 71 | 72 | def bundler_requirement_for(version) 73 | return "#{Gem::Requirement.default}.a" unless version 74 | 75 | bundler_gem_version = Gem::Version.new(version) 76 | 77 | requirement = bundler_gem_version.approximate_recommendation 78 | 79 | return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0") 80 | 81 | requirement += ".a" if bundler_gem_version.prerelease? 82 | 83 | requirement 84 | end 85 | 86 | def load_bundler! 87 | ENV["BUNDLE_GEMFILE"] ||= gemfile 88 | 89 | activate_bundler 90 | end 91 | 92 | def activate_bundler 93 | gem_error = activation_error_handling do 94 | gem "bundler", bundler_requirement 95 | end 96 | return if gem_error.nil? 97 | require_error = activation_error_handling do 98 | require "bundler/version" 99 | end 100 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) 101 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" 102 | exit 42 103 | end 104 | 105 | def activation_error_handling 106 | yield 107 | nil 108 | rescue StandardError, LoadError => e 109 | e 110 | end 111 | end 112 | 113 | m.load_bundler! 114 | 115 | if m.invoked_as_script? 116 | load Gem.bin_path("bundler", "bundle") 117 | end 118 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'active_support/core_ext/integer/time' 4 | 5 | Rails.application.configure do 6 | # Settings specified here will take precedence over those in config/application.rb. 7 | 8 | # Code is not reloaded between requests. 9 | config.cache_classes = true 10 | 11 | # Eager load code on boot. This eager loads most of Rails and 12 | # your application in memory, allowing both threaded web servers 13 | # and those relying on copy on write to perform better. 14 | # Rake tasks automatically ignore this option for performance. 15 | config.eager_load = true 16 | 17 | # Full error reports are disabled and caching is turned on. 18 | config.consider_all_requests_local = false 19 | config.action_controller.perform_caching = true 20 | 21 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 22 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 23 | # config.require_master_key = true 24 | 25 | # Disable serving static files from the `/public` folder by default since 26 | # Apache or NGINX already handles this. 27 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? || ENV['RENDER'].present? 28 | 29 | # Compress CSS using a preprocessor. 30 | # config.assets.css_compressor = :sass 31 | config.assets.css_compressor = nil 32 | 33 | # Do not fallback to assets pipeline if a precompiled asset is missed. 34 | config.assets.compile = false 35 | 36 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 37 | # config.asset_host = "http://assets.example.com" 38 | 39 | # Specifies the header that your server uses for sending files. 40 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache 41 | # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX 42 | 43 | # Store uploaded files on the local file system (see config/storage.yml for options). 44 | config.active_storage.service = :local 45 | 46 | # Mount Action Cable outside main process or domain. 47 | # config.action_cable.mount_path = nil 48 | # config.action_cable.url = "wss://example.com/cable" 49 | # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] 50 | 51 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 52 | # config.force_ssl = true 53 | 54 | # Include generic and useful information about system operation, but avoid logging too much 55 | # information to avoid inadvertent exposure of personally identifiable information (PII). 56 | config.log_level = :info 57 | 58 | # Prepend all log lines with the following tags. 59 | config.log_tags = [:request_id] 60 | 61 | # Use a different cache store in production. 62 | # config.cache_store = :mem_cache_store 63 | 64 | # Use a real queuing backend for Active Job (and separate queues per environment). 65 | # config.active_job.queue_adapter = :resque 66 | # config.active_job.queue_name_prefix = "money_moves_production" 67 | 68 | config.action_mailer.perform_caching = false 69 | 70 | # Ignore bad email addresses and do not raise email delivery errors. 71 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 72 | # config.action_mailer.raise_delivery_errors = false 73 | 74 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 75 | # the I18n.default_locale when a translation cannot be found). 76 | config.i18n.fallbacks = true 77 | 78 | # Don't log any deprecations. 79 | config.active_support.report_deprecations = false 80 | 81 | # Use default logging formatter so that PID and timestamp are not suppressed. 82 | config.log_formatter = ::Logger::Formatter.new 83 | 84 | # Use a different logger for distributed setups. 85 | # require "syslog/logger" 86 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") 87 | 88 | if ENV['RAILS_LOG_TO_STDOUT'].present? 89 | logger = ActiveSupport::Logger.new($stdout) 90 | logger.formatter = config.log_formatter 91 | config.logger = ActiveSupport::TaggedLogging.new(logger) 92 | end 93 | 94 | # Do not dump schema after migrations. 95 | config.active_record.dump_schema_after_migration = false 96 | # config.action_mailer.default_url_options = { host: 'money-moves.onrender.com' } 97 | end 98 | -------------------------------------------------------------------------------- /config/locales/devise.en.yml: -------------------------------------------------------------------------------- 1 | # Additional translations at https://github.com/heartcombo/devise/wiki/I18n 2 | 3 | en: 4 | devise: 5 | confirmations: 6 | confirmed: "Your email address has been successfully confirmed." 7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." 8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." 9 | failure: 10 | already_authenticated: "You are already signed in." 11 | inactive: "Your account is not activated yet." 12 | invalid: "Invalid %{authentication_keys} or password." 13 | locked: "Your account is locked." 14 | last_attempt: "You have one more attempt before your account is locked." 15 | not_found_in_database: "Invalid %{authentication_keys} or password." 16 | timeout: "Your session expired. Please sign in again to continue." 17 | unauthenticated: "You need to sign in or sign up before continuing." 18 | unconfirmed: "You have to confirm your email address before continuing." 19 | mailer: 20 | confirmation_instructions: 21 | subject: "Confirmation instructions" 22 | reset_password_instructions: 23 | subject: "Reset password instructions" 24 | unlock_instructions: 25 | subject: "Unlock instructions" 26 | email_changed: 27 | subject: "Email Changed" 28 | password_change: 29 | subject: "Password Changed" 30 | omniauth_callbacks: 31 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"." 32 | success: "Successfully authenticated from %{kind} account." 33 | passwords: 34 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." 35 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." 36 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." 37 | updated: "Your password has been changed successfully. You are now signed in." 38 | updated_not_active: "Your password has been changed successfully." 39 | registrations: 40 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." 41 | signed_up: "Welcome! You have signed up successfully." 42 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." 43 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." 44 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." 45 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address." 46 | updated: "Your account has been updated successfully." 47 | updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again." 48 | sessions: 49 | signed_in: "Signed in successfully." 50 | signed_out: "Signed out successfully." 51 | already_signed_out: "Signed out successfully." 52 | unlocks: 53 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." 54 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." 55 | unlocked: "Your account has been unlocked successfully. Please sign in to continue." 56 | errors: 57 | messages: 58 | already_confirmed: "was already confirmed, please try signing in" 59 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" 60 | expired: "has expired, please request a new one" 61 | not_found: "not found" 62 | not_locked: "was not locked" 63 | not_saved: 64 | one: "1 error prohibited this %{resource} from being saved:" 65 | other: "%{count} errors prohibited this %{resource} from being saved:" 66 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 16 | RSpec.configure do |config| 17 | # rspec-expectations config goes here. You can use an alternate 18 | # assertion/expectation library such as wrong or the stdlib/minitest 19 | # assertions if you prefer. 20 | config.expect_with :rspec do |expectations| 21 | # This option will default to `true` in RSpec 4. It makes the `description` 22 | # and `failure_message` of custom matchers include text for helper methods 23 | # defined using `chain`, e.g.: 24 | # be_bigger_than(2).and_smaller_than(4).description 25 | # # => "be bigger than 2 and smaller than 4" 26 | # ...rather than: 27 | # # => "be bigger than 2" 28 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 29 | end 30 | 31 | # rspec-mocks config goes here. You can use an alternate test double 32 | # library (such as bogus or mocha) by changing the `mock_with` option here. 33 | config.mock_with :rspec do |mocks| 34 | # Prevents you from mocking or stubbing a method that does not exist on 35 | # a real object. This is generally recommended, and will default to 36 | # `true` in RSpec 4. 37 | mocks.verify_partial_doubles = true 38 | end 39 | 40 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 41 | # have no way to turn it off -- the option exists only for backwards 42 | # compatibility in RSpec 3). It causes shared context metadata to be 43 | # inherited by the metadata hash of host groups and examples, rather than 44 | # triggering implicit auto-inclusion in groups with matching metadata. 45 | config.shared_context_metadata_behavior = :apply_to_host_groups 46 | 47 | # The settings below are suggested to provide a good initial experience 48 | # with RSpec, but feel free to customize to your heart's content. 49 | # # This allows you to limit a spec run to individual examples or groups 50 | # # you care about by tagging them with `:focus` metadata. When nothing 51 | # # is tagged with `:focus`, all examples get run. RSpec also provides 52 | # # aliases for `it`, `describe`, and `context` that include `:focus` 53 | # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 54 | # config.filter_run_when_matching :focus 55 | # 56 | # # Allows RSpec to persist some state between runs in order to support 57 | # # the `--only-failures` and `--next-failure` CLI options. We recommend 58 | # # you configure your source control system to ignore this file. 59 | # config.example_status_persistence_file_path = "spec/examples.txt" 60 | # 61 | # # Limits the available syntax to the non-monkey patched syntax that is 62 | # # recommended. For more details, see: 63 | # # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode 64 | # config.disable_monkey_patching! 65 | # 66 | # # This setting enables warnings. It's recommended, but in some cases may 67 | # # be too noisy due to issues in dependencies. 68 | # config.warnings = true 69 | # 70 | # # Many RSpec users commonly either run the entire suite or an individual 71 | # # file, and it's useful to allow more verbose output when running an 72 | # # individual spec file. 73 | # if config.files_to_run.one? 74 | # # Use the documentation formatter for detailed output, 75 | # # unless a formatter has already been configured 76 | # # (e.g. via a command-line flag). 77 | # config.default_formatter = "doc" 78 | # end 79 | # 80 | # # Print the 10 slowest examples and example groups at the 81 | # # end of the spec run, to help surface which specs are running 82 | # # particularly slow. 83 | # config.profile_examples = 10 84 | # 85 | # # Run specs in random order to surface order dependencies. If you find an 86 | # # order dependency and want to debug it, you can fix the order by providing 87 | # # the seed, which is printed after each run. 88 | # # --seed 1234 89 | # config.order = :random 90 | # 91 | # # Seed global randomization in this process using the `--seed` CLI option. 92 | # # Setting this allows you to use `--seed` to deterministically reproduce 93 | # # test failures related to randomization by passing the same `--seed` value 94 | # # as the one that triggered the failure. 95 | # Kernel.srand config.seed 96 | end 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | logo 4 |
5 | 6 |

MONEY MOVES

7 | 8 |
9 | 10 | 11 | # 📗 Table of Contents 12 | 13 | - [📖 About the Project](#about-project) 14 | - [🛠 Built With](#built-with) 15 | - [Tech Stack](#tech-stack) 16 | - [Key Features](#key-features) 17 | - [🚀 Live Demo](#live-demo) 18 | - [💻 Getting Started](#getting-started) 19 | - [Setup](#setup) 20 | - [Prerequisites](#prerequisites) 21 | - [Install](#install) 22 | - [Usage](#usage) 23 | - [Run tests](#run-tests) 24 | - [Deployment](#triangular_flag_on_post-deployment) 25 | - [👥 Authors](#authors) 26 | - [🔭 Future Features](#future-features) 27 | - [🤝 Contributing](#contributing) 28 | - [⭐️ Show your support](#support) 29 | - [🙏 Acknowledgements](#acknowledgements) 30 | - [❓ FAQ](#faq) 31 | - [📝 License](#license) 32 | 33 | # 📖 Money moves 34 | 35 | This is a mobile web application, which allows users to control their budgets. The user can divide the budget into different categories and insert the expenses that have been made in the categories. 36 | 37 | ## 🛠 Built With 38 | 39 | ### Tech Stack 40 | 41 |
42 | Client 43 | 46 |
47 | 48 |
49 | Server 50 | 53 |
54 | 55 |
56 | Database 57 | 60 |
61 | 62 | ### Key Features 63 | 64 | - List all budget's categories. 65 | - List all transactions that belongs to one category. 66 | - Add a new category. 67 | - Add a new transaction. 68 | 69 |

(back to top)

70 | 71 | ## 🚀 Live Demo 72 | 73 | - [Live Demo Link](https://money-moves.onrender.com) 74 | 75 |

(back to top)

76 | 77 | 78 | 79 | ## 💻 Getting Started 80 | 81 | To get a local copy up and running, follow these steps. 82 | 83 | ### Prerequisites 84 | 85 | In order to run this project you need: 86 | 87 | 88 | ```sh 89 | gem install rails 90 | ``` 91 | 92 | ### Setup 93 | 94 | Clone this repository to your desired folder: 95 | 96 | ```sh 97 | cd my-folder 98 | git clone https://github.com/VaneCode/money_moves.git 99 | ``` 100 | 101 | ### Install 102 | 103 | Install this project with: 104 | 105 | ```sh 106 | cd my-project 107 | gem install 108 | ``` 109 | 110 | ### Usage 111 | 112 | This project use Tailwind, so to run the project, execute the following command: 113 | 114 | 115 | ```sh 116 | bin/dev 117 | ``` 118 | 119 | ### Run tests 120 | 121 | To run tests, run the following command: 122 | 123 | ```sh 124 | bin/rails spec 125 | ``` 126 | 127 | ### Deployment 128 | 129 | You can deploy this project using: 130 | 131 | 132 | ```sh 133 | bin/dev 134 | ``` 135 | 136 |

(back to top)

137 | 138 | ## 👥 Author 139 | 140 | 👤 **Vanessa Bonito** 141 | 142 | - GitHub: [@VaneCode](https://github.com/VaneCode) 143 | - Twitter: [@BonitoNarvaez](https://twitter.com/BonitoNarvaez) 144 | - LinkedIn: [Vanessa Bonito Narváez](https://www.linkedin.com/in/vanessa-bonito-narvaez/) 145 | 146 |

(back to top)

147 | 148 | ## 🔭 Future Features 149 | 150 | - [Implement the left side menu.] **[new_feature_1]** 151 | - [Add dark theme.] **[new_feature_2]** 152 | - [Add user picture profile.] **[new_feature_3]** 153 | 154 |

(back to top)

155 | 156 | ## 🤝 Contributing 157 | 158 | Contributions, issues, and feature requests are welcome! 159 | 160 | Feel free to check the [issues page](../../issues/). 161 | 162 |

(back to top)

163 | 164 | ## ⭐️ Show your support 165 | 166 | Give a star if you like this project! 167 | 168 |

(back to top)

169 | 170 | ## 🙏 Acknowledgments 171 | 172 | - This project's styles are based on the [design](https://www.behance.net/gallery/19759151/Snapscan-iOs-design-and-branding?tracking_source=&&&) by [Gregoire Vella](http://linkedin.com/company/minimalapps). 173 | - Microverse. 174 | 175 |

(back to top)

176 | 177 | ## ❓ FAQ 178 | 179 | - Why bin/dev instead of rails server? 180 | 181 | - The commend bin/dev not only start your server, it also builts your Tailwind CSS classes to give the styles. 182 | 183 | - What is current_user? 184 | 185 | - This is a built-in method of Devise which help to get the user who is currently loged in the app. 186 | 187 |

(back to top)

188 | 189 | 190 | ## 📝 License 191 | 192 | This project is [MIT](./LICENSE) licensed. 193 | 194 |

(back to top)

195 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (7.0.4) 5 | actionpack (= 7.0.4) 6 | activesupport (= 7.0.4) 7 | nio4r (~> 2.0) 8 | websocket-driver (>= 0.6.1) 9 | actionmailbox (7.0.4) 10 | actionpack (= 7.0.4) 11 | activejob (= 7.0.4) 12 | activerecord (= 7.0.4) 13 | activestorage (= 7.0.4) 14 | activesupport (= 7.0.4) 15 | mail (>= 2.7.1) 16 | net-imap 17 | net-pop 18 | net-smtp 19 | actionmailer (7.0.4) 20 | actionpack (= 7.0.4) 21 | actionview (= 7.0.4) 22 | activejob (= 7.0.4) 23 | activesupport (= 7.0.4) 24 | mail (~> 2.5, >= 2.5.4) 25 | net-imap 26 | net-pop 27 | net-smtp 28 | rails-dom-testing (~> 2.0) 29 | actionpack (7.0.4) 30 | actionview (= 7.0.4) 31 | activesupport (= 7.0.4) 32 | rack (~> 2.0, >= 2.2.0) 33 | rack-test (>= 0.6.3) 34 | rails-dom-testing (~> 2.0) 35 | rails-html-sanitizer (~> 1.0, >= 1.2.0) 36 | actiontext (7.0.4) 37 | actionpack (= 7.0.4) 38 | activerecord (= 7.0.4) 39 | activestorage (= 7.0.4) 40 | activesupport (= 7.0.4) 41 | globalid (>= 0.6.0) 42 | nokogiri (>= 1.8.5) 43 | actionview (7.0.4) 44 | activesupport (= 7.0.4) 45 | builder (~> 3.1) 46 | erubi (~> 1.4) 47 | rails-dom-testing (~> 2.0) 48 | rails-html-sanitizer (~> 1.1, >= 1.2.0) 49 | activejob (7.0.4) 50 | activesupport (= 7.0.4) 51 | globalid (>= 0.3.6) 52 | activemodel (7.0.4) 53 | activesupport (= 7.0.4) 54 | activerecord (7.0.4) 55 | activemodel (= 7.0.4) 56 | activesupport (= 7.0.4) 57 | activestorage (7.0.4) 58 | actionpack (= 7.0.4) 59 | activejob (= 7.0.4) 60 | activerecord (= 7.0.4) 61 | activesupport (= 7.0.4) 62 | marcel (~> 1.0) 63 | mini_mime (>= 1.1.0) 64 | activesupport (7.0.4) 65 | concurrent-ruby (~> 1.0, >= 1.0.2) 66 | i18n (>= 1.6, < 2) 67 | minitest (>= 5.1) 68 | tzinfo (~> 2.0) 69 | addressable (2.8.1) 70 | public_suffix (>= 2.0.2, < 6.0) 71 | bcrypt (3.1.18) 72 | bindex (0.8.1) 73 | bootsnap (1.14.0) 74 | msgpack (~> 1.2) 75 | builder (3.2.4) 76 | bullet (7.0.3) 77 | activesupport (>= 3.0.0) 78 | uniform_notifier (~> 1.11) 79 | cancancan (3.4.0) 80 | capybara (3.38.0) 81 | addressable 82 | matrix 83 | mini_mime (>= 0.1.3) 84 | nokogiri (~> 1.8) 85 | rack (>= 1.6.0) 86 | rack-test (>= 0.6.3) 87 | regexp_parser (>= 1.5, < 3.0) 88 | xpath (~> 3.2) 89 | childprocess (4.1.0) 90 | concurrent-ruby (1.1.10) 91 | crass (1.0.6) 92 | database_cleaner (2.0.1) 93 | database_cleaner-active_record (~> 2.0.0) 94 | database_cleaner-active_record (2.0.1) 95 | activerecord (>= 5.a) 96 | database_cleaner-core (~> 2.0.0) 97 | database_cleaner-core (2.0.1) 98 | debug (1.6.3) 99 | irb (>= 1.3.6) 100 | reline (>= 0.3.1) 101 | devise (4.8.1) 102 | bcrypt (~> 3.0) 103 | orm_adapter (~> 0.1) 104 | railties (>= 4.1.0) 105 | responders 106 | warden (~> 1.2.3) 107 | diff-lcs (1.5.0) 108 | dotenv (2.8.1) 109 | dotenv-rails (2.8.1) 110 | dotenv (= 2.8.1) 111 | railties (>= 3.2) 112 | erubi (1.11.0) 113 | faker (3.0.0) 114 | i18n (>= 1.8.11, < 2) 115 | ffi (1.15.5) 116 | ffi (1.15.5-x64-mingw-ucrt) 117 | globalid (1.0.0) 118 | activesupport (>= 5.0) 119 | i18n (1.12.0) 120 | concurrent-ruby (~> 1.0) 121 | importmap-rails (1.1.5) 122 | actionpack (>= 6.0.0) 123 | railties (>= 6.0.0) 124 | io-console (0.5.11) 125 | irb (1.5.0) 126 | reline (>= 0.3.0) 127 | jbuilder (2.11.5) 128 | actionview (>= 5.0.0) 129 | activesupport (>= 5.0.0) 130 | loofah (2.19.0) 131 | crass (~> 1.0.2) 132 | nokogiri (>= 1.5.9) 133 | mail (2.7.1) 134 | mini_mime (>= 0.1.1) 135 | marcel (1.0.2) 136 | matrix (0.4.2) 137 | method_source (1.0.0) 138 | mini_mime (1.1.2) 139 | minitest (5.16.3) 140 | msgpack (1.6.0) 141 | net-imap (0.3.1) 142 | net-protocol 143 | net-pop (0.1.2) 144 | net-protocol 145 | net-protocol (0.1.3) 146 | timeout 147 | net-smtp (0.3.3) 148 | net-protocol 149 | nio4r (2.5.8) 150 | nokogiri (1.13.9-x64-mingw-ucrt) 151 | racc (~> 1.4) 152 | nokogiri (1.13.9-x86_64-linux) 153 | racc (~> 1.4) 154 | orm_adapter (0.5.0) 155 | pg (1.4.5) 156 | pg (1.4.5-x64-mingw-ucrt) 157 | public_suffix (5.0.0) 158 | puma (5.6.5) 159 | nio4r (~> 2.0) 160 | racc (1.6.0) 161 | rack (2.2.4) 162 | rack-test (2.0.2) 163 | rack (>= 1.3) 164 | rails (7.0.4) 165 | actioncable (= 7.0.4) 166 | actionmailbox (= 7.0.4) 167 | actionmailer (= 7.0.4) 168 | actionpack (= 7.0.4) 169 | actiontext (= 7.0.4) 170 | actionview (= 7.0.4) 171 | activejob (= 7.0.4) 172 | activemodel (= 7.0.4) 173 | activerecord (= 7.0.4) 174 | activestorage (= 7.0.4) 175 | activesupport (= 7.0.4) 176 | bundler (>= 1.15.0) 177 | railties (= 7.0.4) 178 | rails-controller-testing (1.0.5) 179 | actionpack (>= 5.0.1.rc1) 180 | actionview (>= 5.0.1.rc1) 181 | activesupport (>= 5.0.1.rc1) 182 | rails-dom-testing (2.0.3) 183 | activesupport (>= 4.2.0) 184 | nokogiri (>= 1.6) 185 | rails-html-sanitizer (1.4.3) 186 | loofah (~> 2.3) 187 | railties (7.0.4) 188 | actionpack (= 7.0.4) 189 | activesupport (= 7.0.4) 190 | method_source 191 | rake (>= 12.2) 192 | thor (~> 1.0) 193 | zeitwerk (~> 2.5) 194 | rake (13.0.6) 195 | regexp_parser (2.6.1) 196 | reline (0.3.1) 197 | io-console (~> 0.5) 198 | responders (3.0.1) 199 | actionpack (>= 5.0) 200 | railties (>= 5.0) 201 | rexml (3.2.5) 202 | rspec-core (3.12.0) 203 | rspec-support (~> 3.12.0) 204 | rspec-expectations (3.12.0) 205 | diff-lcs (>= 1.2.0, < 2.0) 206 | rspec-support (~> 3.12.0) 207 | rspec-mocks (3.12.0) 208 | diff-lcs (>= 1.2.0, < 2.0) 209 | rspec-support (~> 3.12.0) 210 | rspec-rails (6.0.1) 211 | actionpack (>= 6.1) 212 | activesupport (>= 6.1) 213 | railties (>= 6.1) 214 | rspec-core (~> 3.11) 215 | rspec-expectations (~> 3.11) 216 | rspec-mocks (~> 3.11) 217 | rspec-support (~> 3.11) 218 | rspec-support (3.12.0) 219 | rubyzip (2.3.2) 220 | selenium-webdriver (4.6.1) 221 | childprocess (>= 0.5, < 5.0) 222 | rexml (~> 3.2, >= 3.2.5) 223 | rubyzip (>= 1.2.2, < 3.0) 224 | websocket (~> 1.0) 225 | sprockets (4.1.1) 226 | concurrent-ruby (~> 1.0) 227 | rack (> 1, < 3) 228 | sprockets-rails (3.4.2) 229 | actionpack (>= 5.2) 230 | activesupport (>= 5.2) 231 | sprockets (>= 3.0.0) 232 | stimulus-rails (1.1.1) 233 | railties (>= 6.0.0) 234 | tailwindcss-rails (2.0.21-x64-mingw-ucrt) 235 | railties (>= 6.0.0) 236 | tailwindcss-rails (2.0.21-x86_64-linux) 237 | railties (>= 6.0.0) 238 | thor (1.2.1) 239 | timeout (0.3.0) 240 | turbo-rails (1.3.2) 241 | actionpack (>= 6.0.0) 242 | activejob (>= 6.0.0) 243 | railties (>= 6.0.0) 244 | tzinfo (2.0.5) 245 | concurrent-ruby (~> 1.0) 246 | tzinfo-data (1.2022.6) 247 | tzinfo (>= 1.0.0) 248 | uniform_notifier (1.16.0) 249 | warden (1.2.9) 250 | rack (>= 2.0.9) 251 | web-console (4.2.0) 252 | actionview (>= 6.0.0) 253 | activemodel (>= 6.0.0) 254 | bindex (>= 0.4.0) 255 | railties (>= 6.0.0) 256 | webdrivers (5.2.0) 257 | nokogiri (~> 1.6) 258 | rubyzip (>= 1.3.0) 259 | selenium-webdriver (~> 4.0) 260 | websocket (1.2.9) 261 | websocket-driver (0.7.5) 262 | websocket-extensions (>= 0.1.0) 263 | websocket-extensions (0.1.5) 264 | xpath (3.2.0) 265 | nokogiri (~> 1.8) 266 | zeitwerk (2.6.6) 267 | 268 | PLATFORMS 269 | x64-mingw-ucrt 270 | x86_64-linux 271 | 272 | DEPENDENCIES 273 | bootsnap 274 | bullet 275 | cancancan 276 | capybara 277 | database_cleaner 278 | debug 279 | devise 280 | dotenv-rails 281 | faker 282 | ffi 283 | importmap-rails 284 | jbuilder 285 | pg (~> 1.1) 286 | puma (~> 5.0) 287 | rails (~> 7.0.4) 288 | rails-controller-testing 289 | rspec-rails 290 | selenium-webdriver 291 | sprockets-rails 292 | stimulus-rails 293 | tailwindcss-rails (~> 2.0) 294 | turbo-rails 295 | tzinfo-data 296 | web-console 297 | webdrivers 298 | 299 | RUBY VERSION 300 | ruby 3.1.2p20 301 | 302 | BUNDLED WITH 303 | 2.3.24 304 | -------------------------------------------------------------------------------- /config/initializers/devise.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Assuming you have not yet modified this file, each configuration option below 4 | # is set to its default value. Note that some are commented out while others 5 | # are not: uncommented lines are intended to protect your configuration from 6 | # breaking changes in upgrades (i.e., in the event that future versions of 7 | # Devise change the default values for those options). 8 | # 9 | # Use this hook to configure devise mailer, warden hooks and so forth. 10 | # Many of these configuration options can be set straight in your model. 11 | Devise.setup do |config| 12 | # The secret key used by Devise. Devise uses this key to generate 13 | # random tokens. Changing this key will render invalid all existing 14 | # confirmation, reset password and unlock tokens in the database. 15 | # Devise will use the `secret_key_base` as its `secret_key` 16 | # by default. You can change it below and use your own secret key. 17 | # config.secret_key = '4249842b0a4e4460e3081ef9077ff464fefbaed5586916a27ee3a41183f4a5e30ec77adca5cd1b42d835416c5511b85eb82acae3cb8c55e913e04bc9f802c567' 18 | 19 | # ==> Controller configuration 20 | # Configure the parent class to the devise controllers. 21 | # config.parent_controller = 'DeviseController' 22 | 23 | # ==> Mailer Configuration 24 | # Configure the e-mail address which will be shown in Devise::Mailer, 25 | # note that it will be overwritten if you use your own mailer class 26 | # with default "from" parameter. 27 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' 28 | 29 | # Configure the class responsible to send e-mails. 30 | # config.mailer = 'Devise::Mailer' 31 | 32 | # Configure the parent class responsible to send e-mails. 33 | # config.parent_mailer = 'ActionMailer::Base' 34 | 35 | # ==> ORM configuration 36 | # Load and configure the ORM. Supports :active_record (default) and 37 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 38 | # available as additional gems. 39 | require 'devise/orm/active_record' 40 | 41 | # ==> Configuration for any authentication mechanism 42 | # Configure which keys are used when authenticating a user. The default is 43 | # just :email. You can configure it to use [:username, :subdomain], so for 44 | # authenticating a user, both parameters are required. Remember that those 45 | # parameters are used only when authenticating and not when retrieving from 46 | # session. If you need permissions, you should implement that in a before filter. 47 | # You can also supply a hash where the value is a boolean determining whether 48 | # or not authentication should be aborted when the value is not present. 49 | # config.authentication_keys = [:email] 50 | 51 | # Configure parameters from the request object used for authentication. Each entry 52 | # given should be a request method and it will automatically be passed to the 53 | # find_for_authentication method and considered in your model lookup. For instance, 54 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 55 | # The same considerations mentioned for authentication_keys also apply to request_keys. 56 | # config.request_keys = [] 57 | 58 | # Configure which authentication keys should be case-insensitive. 59 | # These keys will be downcased upon creating or modifying a user and when used 60 | # to authenticate or find a user. Default is :email. 61 | config.case_insensitive_keys = [:email] 62 | 63 | # Configure which authentication keys should have whitespace stripped. 64 | # These keys will have whitespace before and after removed upon creating or 65 | # modifying a user and when used to authenticate or find a user. Default is :email. 66 | config.strip_whitespace_keys = [:email] 67 | 68 | # Tell if authentication through request.params is enabled. True by default. 69 | # It can be set to an array that will enable params authentication only for the 70 | # given strategies, for example, `config.params_authenticatable = [:database]` will 71 | # enable it only for database (email + password) authentication. 72 | # config.params_authenticatable = true 73 | 74 | # Tell if authentication through HTTP Auth is enabled. False by default. 75 | # It can be set to an array that will enable http authentication only for the 76 | # given strategies, for example, `config.http_authenticatable = [:database]` will 77 | # enable it only for database authentication. 78 | # For API-only applications to support authentication "out-of-the-box", you will likely want to 79 | # enable this with :database unless you are using a custom strategy. 80 | # The supported strategies are: 81 | # :database = Support basic authentication with authentication key + password 82 | # config.http_authenticatable = false 83 | 84 | # If 401 status code should be returned for AJAX requests. True by default. 85 | # config.http_authenticatable_on_xhr = true 86 | 87 | # The realm used in Http Basic Authentication. 'Application' by default. 88 | # config.http_authentication_realm = 'Application' 89 | 90 | # It will change confirmation, password recovery and other workflows 91 | # to behave the same regardless if the e-mail provided was right or wrong. 92 | # Does not affect registerable. 93 | # config.paranoid = true 94 | 95 | # By default Devise will store the user in session. You can skip storage for 96 | # particular strategies by setting this option. 97 | # Notice that if you are skipping storage for all authentication paths, you 98 | # may want to disable generating routes to Devise's sessions controller by 99 | # passing skip: :sessions to `devise_for` in your config/routes.rb 100 | config.skip_session_storage = [:http_auth] 101 | 102 | # By default, Devise cleans up the CSRF token on authentication to 103 | # avoid CSRF token fixation attacks. This means that, when using AJAX 104 | # requests for sign in and sign up, you need to get a new CSRF token 105 | # from the server. You can disable this option at your own risk. 106 | # config.clean_up_csrf_token_on_authentication = true 107 | 108 | # When false, Devise will not attempt to reload routes on eager load. 109 | # This can reduce the time taken to boot the app but if your application 110 | # requires the Devise mappings to be loaded during boot time the application 111 | # won't boot properly. 112 | # config.reload_routes = true 113 | 114 | # ==> Configuration for :database_authenticatable 115 | # For bcrypt, this is the cost for hashing the password and defaults to 12. If 116 | # using other algorithms, it sets how many times you want the password to be hashed. 117 | # The number of stretches used for generating the hashed password are stored 118 | # with the hashed password. This allows you to change the stretches without 119 | # invalidating existing passwords. 120 | # 121 | # Limiting the stretches to just one in testing will increase the performance of 122 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 123 | # a value less than 10 in other environments. Note that, for bcrypt (the default 124 | # algorithm), the cost increases exponentially with the number of stretches (e.g. 125 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). 126 | config.stretches = Rails.env.test? ? 1 : 12 127 | 128 | # Set up a pepper to generate the hashed password. 129 | # config.pepper = '21413c6e5acc843740022468eccb011c1c2fe8ce4ac271145ca7f75b85097893fa3fca9acc5cfee698785f449e407042aea941dc3b61c5710b78e0580c1483b1' 130 | 131 | # Send a notification to the original email when the user's email is changed. 132 | # config.send_email_changed_notification = false 133 | 134 | # Send a notification email when the user's password is changed. 135 | # config.send_password_change_notification = false 136 | 137 | # ==> Configuration for :confirmable 138 | # A period that the user is allowed to access the website even without 139 | # confirming their account. For instance, if set to 2.days, the user will be 140 | # able to access the website for two days without confirming their account, 141 | # access will be blocked just in the third day. 142 | # You can also set it to nil, which will allow the user to access the website 143 | # without confirming their account. 144 | # Default is 0.days, meaning the user cannot access the website without 145 | # confirming their account. 146 | # config.allow_unconfirmed_access_for = 2.days 147 | 148 | # A period that the user is allowed to confirm their account before their 149 | # token becomes invalid. For example, if set to 3.days, the user can confirm 150 | # their account within 3 days after the mail was sent, but on the fourth day 151 | # their account can't be confirmed with the token any more. 152 | # Default is nil, meaning there is no restriction on how long a user can take 153 | # before confirming their account. 154 | # config.confirm_within = 3.days 155 | 156 | # If true, requires any email changes to be confirmed (exactly the same way as 157 | # initial account confirmation) to be applied. Requires additional unconfirmed_email 158 | # db field (see migrations). Until confirmed, new email is stored in 159 | # unconfirmed_email column, and copied to email column on successful confirmation. 160 | config.reconfirmable = true 161 | 162 | # Defines which key will be used when confirming an account 163 | # config.confirmation_keys = [:email] 164 | 165 | # ==> Configuration for :rememberable 166 | # The time the user will be remembered without asking for credentials again. 167 | # config.remember_for = 2.weeks 168 | 169 | # Invalidates all the remember me tokens when the user signs out. 170 | config.expire_all_remember_me_on_sign_out = true 171 | 172 | # If true, extends the user's remember period when remembered via cookie. 173 | # config.extend_remember_period = false 174 | 175 | # Options to be passed to the created cookie. For instance, you can set 176 | # secure: true in order to force SSL only cookies. 177 | # config.rememberable_options = {} 178 | 179 | # ==> Configuration for :validatable 180 | # Range for password length. 181 | config.password_length = 6..128 182 | 183 | # Email regex used to validate email formats. It simply asserts that 184 | # one (and only one) @ exists in the given string. This is mainly 185 | # to give user feedback and not to assert the e-mail validity. 186 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ 187 | 188 | # ==> Configuration for :timeoutable 189 | # The time you want to timeout the user session without activity. After this 190 | # time the user will be asked for credentials again. Default is 30 minutes. 191 | # config.timeout_in = 30.minutes 192 | 193 | # ==> Configuration for :lockable 194 | # Defines which strategy will be used to lock an account. 195 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 196 | # :none = No lock strategy. You should handle locking by yourself. 197 | # config.lock_strategy = :failed_attempts 198 | 199 | # Defines which key will be used when locking and unlocking an account 200 | # config.unlock_keys = [:email] 201 | 202 | # Defines which strategy will be used to unlock an account. 203 | # :email = Sends an unlock link to the user email 204 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 205 | # :both = Enables both strategies 206 | # :none = No unlock strategy. You should handle unlocking by yourself. 207 | # config.unlock_strategy = :both 208 | 209 | # Number of authentication tries before locking an account if lock_strategy 210 | # is failed attempts. 211 | # config.maximum_attempts = 20 212 | 213 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 214 | # config.unlock_in = 1.hour 215 | 216 | # Warn on the last attempt before the account is locked. 217 | # config.last_attempt_warning = true 218 | 219 | # ==> Configuration for :recoverable 220 | # 221 | # Defines which key will be used when recovering the password for an account 222 | # config.reset_password_keys = [:email] 223 | 224 | # Time interval you can reset your password with a reset password key. 225 | # Don't put a too small interval or your users won't have the time to 226 | # change their passwords. 227 | config.reset_password_within = 6.hours 228 | 229 | # When set to false, does not sign a user in automatically after their password is 230 | # reset. Defaults to true, so a user is signed in automatically after a reset. 231 | # config.sign_in_after_reset_password = true 232 | 233 | # ==> Configuration for :encryptable 234 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default). 235 | # You can use :sha1, :sha512 or algorithms from others authentication tools as 236 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 237 | # for default behavior) and :restful_authentication_sha1 (then you should set 238 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). 239 | # 240 | # Require the `devise-encryptable` gem when using anything other than bcrypt 241 | # config.encryptor = :sha512 242 | 243 | # ==> Scopes configuration 244 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 245 | # "users/sessions/new". It's turned off by default because it's slower if you 246 | # are using only default views. 247 | # config.scoped_views = false 248 | 249 | # Configure the default scope given to Warden. By default it's the first 250 | # devise role declared in your routes (usually :user). 251 | # config.default_scope = :user 252 | 253 | # Set this configuration to false if you want /users/sign_out to sign out 254 | # only the current scope. By default, Devise signs out all scopes. 255 | # config.sign_out_all_scopes = true 256 | 257 | # ==> Navigation configuration 258 | # Lists the formats that should be treated as navigational. Formats like 259 | # :html, should redirect to the sign in page when the user does not have 260 | # access, but formats like :xml or :json, should return 401. 261 | # 262 | # If you have any extra navigational formats, like :iphone or :mobile, you 263 | # should add them to the navigational formats lists. 264 | # 265 | # The "*/*" below is required to match Internet Explorer requests. 266 | # config.navigational_formats = ['*/*', :html] 267 | 268 | # The default HTTP method used to sign out a resource. Default is :delete. 269 | config.sign_out_via = :delete 270 | 271 | # ==> OmniAuth 272 | # Add a new OmniAuth provider. Check the wiki for more information on setting 273 | # up on your models and hooks. 274 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' 275 | 276 | # ==> Warden configuration 277 | # If you want to use other strategies, that are not supported by Devise, or 278 | # change the failure app, you can configure them inside the config.warden block. 279 | # 280 | # config.warden do |manager| 281 | # manager.intercept_401 = false 282 | # manager.default_strategies(scope: :user).unshift :some_external_strategy 283 | # end 284 | 285 | # ==> Mountable engine configurations 286 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine 287 | # is mountable, there are some extra configurations to be taken into account. 288 | # The following options are available, assuming the engine is mounted as: 289 | # 290 | # mount MyEngine, at: '/my_engine' 291 | # 292 | # The router that invoked `devise_for`, in the example above, would be: 293 | # config.router_name = :my_engine 294 | # 295 | # When using OmniAuth, Devise cannot automatically set OmniAuth path, 296 | # so you need to do it manually. For the users scope, it would be: 297 | # config.omniauth_path_prefix = '/my_engine/users/auth' 298 | 299 | # ==> Turbolinks configuration 300 | # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly: 301 | # 302 | # ActiveSupport.on_load(:devise_failure_app) do 303 | # include Turbolinks::Controller 304 | # end 305 | 306 | # ==> Configuration for :registerable 307 | 308 | # When set to false, does not sign a user in automatically after their password is 309 | # changed. Defaults to true, so a user is signed in automatically after changing a password. 310 | # config.sign_in_after_change_password = true 311 | end 312 | --------------------------------------------------------------------------------