Skip to content

Commit

Permalink
Code cleanup: Bug fix repeating code
Browse files Browse the repository at this point in the history
  • Loading branch information
RileyManda committed Jan 23, 2024
1 parent 1b0dae0 commit c8bcb68
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ gem 'pg', '~> 1.1'
gem 'devise'
gem 'devise_token_auth', '>= 1.2.2', git: 'https://github.com/lynndylanhurley/devise_token_auth'
gem 'puma', '>= 5.0'
gem 'rswag'

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
# gem "jbuilder"
Expand Down
24 changes: 24 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.2.0)
bcrypt (3.1.20)
bigdecimal (3.1.6)
Expand Down Expand Up @@ -114,6 +116,8 @@ GEM
irb (1.11.1)
rdoc
reline (>= 0.4.2)
json-schema (4.1.1)
addressable (>= 2.8)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -145,6 +149,7 @@ GEM
pg (1.5.4)
psych (5.1.2)
stringio
public_suffix (5.0.4)
puma (6.4.2)
nio4r (~> 2.0)
racc (1.7.3)
Expand Down Expand Up @@ -193,6 +198,24 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rswag (2.13.0)
rswag-api (= 2.13.0)
rswag-specs (= 2.13.0)
rswag-ui (= 2.13.0)
rswag-api (2.13.0)
activesupport (>= 3.1, < 7.2)
railties (>= 3.1, < 7.2)
rswag-specs (2.13.0)
activesupport (>= 3.1, < 7.2)
json-schema (>= 2.2, < 5.0)
railties (>= 3.1, < 7.2)
rspec-core (>= 2.14)
rswag-ui (2.13.0)
actionpack (>= 3.1, < 7.2)
railties (>= 3.1, < 7.2)
ruby2_keywords (0.0.5)
stringio (3.1.0)
thor (1.3.0)
Expand All @@ -219,6 +242,7 @@ DEPENDENCIES
pg (~> 1.1)
puma (>= 5.0)
rails (~> 7.1.2)
rswag
tzinfo-data

RUBY VERSION
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Api::V1::CategoriesController < ApplicationController
def index
def index
@categories = Api::V1::Category.all
@categories.each do |category|
category.event_count = category.events.count
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/api/v1/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Api::V1::EventsController < ApplicationController
def index
@events = Api::V1::Event.all
def index
@events = Api::V1::Event.all
end

# GET /events/1 or /events/1.json
Expand Down Expand Up @@ -67,4 +67,3 @@ def event_params
:banner, :category_id, :tickets)
end
end

4 changes: 1 addition & 3 deletions app/controllers/api/v1/participants_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Api::V1::ParticipantsController < ApplicationController
def index; end
def index
def index
@participants = Participant.all
end

Expand Down Expand Up @@ -65,4 +64,3 @@ def participant_params
params.require(:participant).permit(:name, :email, :event_id, :attending)
end
end

2 changes: 1 addition & 1 deletion app/models/api/v1/event.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Api::V1::Event < ApplicationRecord
self.table_name = 'events'
self.table_name = 'events'
end

0 comments on commit c8bcb68

Please sign in to comment.