show onboarding page when currency is not set
This commit is contained in:
@@ -1,6 +1,29 @@
|
|||||||
class ChipsController < ApplicationController
|
class ChipsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
json_response Chip.where(enabled: true).order(:name).to_json(include: :base_chip_values)
|
all_chips = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'US Dollar',
|
||||||
|
symbol: '$',
|
||||||
|
code: 'USD',
|
||||||
|
prefixed: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: 'Bosnian Convertible Mark',
|
||||||
|
symbol: 'KM',
|
||||||
|
code: 'BAM',
|
||||||
|
prefixed: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
name: 'Euro',
|
||||||
|
symbol: '€',
|
||||||
|
code: 'EUR',
|
||||||
|
prefixed: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
json_response all_chips
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -46,8 +46,7 @@ class HomiesController < ApplicationController
|
|||||||
params.require(:homie).permit(
|
params.require(:homie).permit(
|
||||||
:name,
|
:name,
|
||||||
:importance,
|
:importance,
|
||||||
:about,
|
:about
|
||||||
:chip_id
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
28
app/controllers/original_gangstas_controller.rb
Normal file
28
app/controllers/original_gangstas_controller.rb
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
class OriginalGangstasController < ApplicationController
|
||||||
|
def show
|
||||||
|
if OriginalGangsta.count.zero?
|
||||||
|
OriginalGangsta.create.save
|
||||||
|
end
|
||||||
|
|
||||||
|
json_response OriginalGangsta.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if original_gangsta_params[:chip_scale].to_i.positive?
|
||||||
|
OriginalGangsta.update(original_gangsta_params)
|
||||||
|
json_response onboarded: true
|
||||||
|
else
|
||||||
|
error_response :bad_request
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def original_gangsta_params
|
||||||
|
params.require(:original_gangsta).permit :chip_name,
|
||||||
|
:chip_code,
|
||||||
|
:chip_symbol,
|
||||||
|
:chip_scale,
|
||||||
|
:chip_prefixed
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
class Homie < ApplicationRecord
|
class Homie < ApplicationRecord
|
||||||
has_many :money_moves
|
has_many :money_moves
|
||||||
has_many :work
|
has_many :work
|
||||||
belongs_to :chip
|
|
||||||
|
|
||||||
def self.info(importance)
|
def self.info(importance)
|
||||||
cash_totals = Homie.all.joins(:money_moves).group(:id).order(:id).sum(:amount)
|
cash_totals = Homie.all.joins(:money_moves).group(:id).order(:id).sum(:amount)
|
||||||
|
|||||||
3
app/models/original_gangsta.rb
Normal file
3
app/models/original_gangsta.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class OriginalGangsta < ApplicationRecord
|
||||||
|
|
||||||
|
end
|
||||||
@@ -17,4 +17,5 @@
|
|||||||
|
|
||||||
ActiveSupport::Inflector.inflections do |inflect|
|
ActiveSupport::Inflector.inflections do |inflect|
|
||||||
inflect.irregular 'work', 'work'
|
inflect.irregular 'work', 'work'
|
||||||
|
inflect.irregular 'gangsta', 'gangstas'
|
||||||
end
|
end
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
constraints format: :json do
|
constraints format: :json do
|
||||||
scope :api do
|
scope :api do
|
||||||
|
resources :original_gangstas, only: [:show, :update]
|
||||||
resources :money_moves
|
resources :money_moves
|
||||||
resources :work
|
resources :work
|
||||||
resources :chips, only: %i[index create destroy]
|
resources :chips, only: %i[index create destroy]
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class RemoveDefaultChipRefFromHomies < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
remove_reference :homies, :chip
|
||||||
|
end
|
||||||
|
end
|
||||||
13
db/migrate/20201006120951_create_original_gangstas.rb
Normal file
13
db/migrate/20201006120951_create_original_gangstas.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
class CreateOriginalGangstas < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :original_gangstas do |t|
|
||||||
|
t.text :chip_name
|
||||||
|
t.text :chip_code
|
||||||
|
t.text :chip_symbol
|
||||||
|
t.boolean :chip_prefixed
|
||||||
|
t.integer :chip_scale
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
14
db/schema.rb
14
db/schema.rb
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2020_10_06_103421) do
|
ActiveRecord::Schema.define(version: 2020_10_06_120951) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -41,8 +41,6 @@ ActiveRecord::Schema.define(version: 2020_10_06_103421) do
|
|||||||
t.text "about"
|
t.text "about"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.bigint "chip_id"
|
|
||||||
t.index ["chip_id"], name: "index_homies_on_chip_id"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "money_moves", force: :cascade do |t|
|
create_table "money_moves", force: :cascade do |t|
|
||||||
@@ -53,6 +51,16 @@ ActiveRecord::Schema.define(version: 2020_10_06_103421) do
|
|||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "original_gangstas", force: :cascade do |t|
|
||||||
|
t.text "chip_name"
|
||||||
|
t.text "chip_code"
|
||||||
|
t.text "chip_symbol"
|
||||||
|
t.boolean "chip_prefixed"
|
||||||
|
t.integer "chip_scale"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "work", force: :cascade do |t|
|
create_table "work", force: :cascade do |t|
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.integer "amount"
|
t.integer "amount"
|
||||||
|
|||||||
Reference in New Issue
Block a user