Skip to content
Open
Show file tree
Hide file tree
Changes from 122 commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
8bac5b0
minor fixes
techiealiraza Jun 2, 2023
9685bc3
Merge branch 'develop' of https://github.com/techiealiraza/rock-pappe…
techiealiraza Jun 2, 2023
c63eb8b
refactored
progammer743 Jun 4, 2023
eab445d
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 4, 2023
f4578e3
leaderBoard query optimized
progammer743 Jun 5, 2023
b8703d4
session find_by_email
techiealiraza Jun 5, 2023
f443726
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 5, 2023
30a66ca
enum roles defined
progammer743 Jun 5, 2023
0a4d12c
find removed from tournament_index_view
progammer743 Jun 5, 2023
c1be315
session controller fixed
techiealiraza Jun 5, 2023
a906740
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 5, 2023
503a783
session controller
techiealiraza Jun 5, 2023
b15f867
matches index
techiealiraza Jun 5, 2023
ce66ae2
offset issue resolved
progammer743 Jun 5, 2023
17b17d3
Merge remote-tracking branch 'refs/remotes/origin/develop_new' into d…
progammer743 Jun 5, 2023
1e770b0
undefined winner name fixed
progammer743 Jun 5, 2023
d419bcb
brackets and spacings
techiealiraza Jun 5, 2023
0f93138
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 5, 2023
ee7e900
rename column name match_time to time & message to content
progammer743 Jun 5, 2023
0bb6c22
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 5, 2023
03e7102
selection name in selections to choice
progammer743 Jun 5, 2023
34544af
renamed column from match_winner_id to winner_id
progammer743 Jun 5, 2023
26f80da
rename column tournament_winner_id to winner_id
progammer743 Jun 5, 2023
6e93ee0
session fixes
techiealiraza Jun 5, 2023
fb05e39
Session Fixes
techiealiraza Jun 5, 2023
6f011a7
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 5, 2023
0c55f34
session fixed
techiealiraza Jun 5, 2023
5f7824b
removed unused params method from matches_controller
progammer743 Jun 5, 2023
ae05494
removed winner
progammer743 Jun 5, 2023
6bf4edf
added params to matcehs
progammer743 Jun 5, 2023
2c5342f
Merge remote-tracking branch 'refs/remotes/origin/develop_new' into d…
progammer743 Jun 5, 2023
058b238
removed params & aincludes winner
progammer743 Jun 5, 2023
37efbda
includes user in selections
progammer743 Jun 5, 2023
9f9d99c
choices updated in match model
progammer743 Jun 5, 2023
a8106b7
validation
techiealiraza Jun 5, 2023
3b8b882
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 5, 2023
b7c4da4
controller load_and_authorize fixed
techiealiraza Jun 6, 2023
432274d
comments resolved
progammer743 Jun 6, 2023
6eed13c
Merge remote-tracking branch 'refs/remotes/origin/develop_new' into d…
progammer743 Jun 6, 2023
ff31f54
removed un-used code & refactored
progammer743 Jun 6, 2023
83f6818
removed unused scopes
progammer743 Jun 7, 2023
6206f9a
space removed
techiealiraza Jun 7, 2023
dd56a25
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 7, 2023
0293f8a
replaced ' with " for consistency
techiealiraza Jun 7, 2023
483fc73
' ' to "" changed
techiealiraza Jun 7, 2023
0c33b29
renamed partial of choice_image
progammer743 Jun 7, 2023
01f5de8
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 7, 2023
014230d
selection ability updated
progammer743 Jun 7, 2023
6c6f70e
deleted unnecessary files
techiealiraza Jun 7, 2023
dc3db55
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 7, 2023
8984936
removed comment from load_controller.js
progammer743 Jun 7, 2023
2496747
text size responsiveness in choice_timer
progammer743 Jun 7, 2023
d174db3
added scopes in tournament model
progammer743 Jun 7, 2023
f241a91
resolved commits
progammer743 Jun 7, 2023
ba5eec0
match controller + views updated
progammer743 Jun 7, 2023
b719e16
message controller
techiealiraza Jun 8, 2023
0371c6b
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 8, 2023
1290b14
added match done/un_done scopes in match model
progammer743 Jun 8, 2023
e2d3948
Merge remote-tracking branch 'refs/remotes/origin/develop_new' into d…
progammer743 Jun 8, 2023
585f57c
respond_to fixed
techiealiraza Jun 8, 2023
15612e2
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 8, 2023
4f3dfe8
comments resolved
progammer743 Jun 8, 2023
91d0fd9
renamed tournamentMatchCreator & removed un-used methods from tournam…
progammer743 Jun 8, 2023
c6a32e8
refactored and added js views for create action of msg and selection
progammer743 Jun 9, 2023
88f3d63
image validation added
techiealiraza Jun 9, 2023
ecf5719
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 9, 2023
08bc5e4
Image Validations
techiealiraza Jun 9, 2023
3e8540e
refactored code
progammer743 Jun 9, 2023
52f176e
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 9, 2023
a6a1c91
updated variables_names & refactored
progammer743 Jun 9, 2023
78a4d85
removed un-used includes
progammer743 Jun 9, 2023
b67c214
gem file
techiealiraza Jun 11, 2023
1b0599e
followed camelCase in js & moved model code from Delayed Job
progammer743 Jun 11, 2023
4f743c0
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 11, 2023
7e7f7f8
validation
techiealiraza Jun 12, 2023
b429d5a
image validation
techiealiraza Jun 12, 2023
d4b5ea9
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 12, 2023
ad41d0e
after perform of MAtch Play job is moved to Service
progammer743 Jun 12, 2023
9b2f84c
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 12, 2023
a670aa2
added callback to selection create & removed user_id hidden field mes…
progammer743 Jun 12, 2023
9db7725
rename un_done to undone
progammer743 Jun 12, 2023
f1deb15
DRY
techiealiraza Jun 12, 2023
8485ce0
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 12, 2023
372a718
removed unused method from the match model
progammer743 Jun 12, 2023
98d4da9
wrong route error handled
techiealiraza Jun 12, 2023
be4de17
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 12, 2023
994534e
rename play_match_channel to match_channel
progammer743 Jun 12, 2023
b920d12
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 12, 2023
68bd19a
gem file
techiealiraza Jun 12, 2023
310e49b
removed unused gems
progammer743 Jun 12, 2023
f2bfc57
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 12, 2023
ab8dc1e
gem
techiealiraza Jun 12, 2023
6a66a0c
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 12, 2023
4d1895a
session alert problem fixed
techiealiraza Jun 12, 2023
bdd4890
refactored and removed unused code
progammer743 Jun 12, 2023
ea00633
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 12, 2023
bef894f
refactored code
progammer743 Jun 13, 2023
2b94b97
removed unused code from match.rb
progammer743 Jun 13, 2023
6e79e22
routes fixed
techiealiraza Jun 13, 2023
c3a9139
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 13, 2023
2b1225a
updated routes
progammer743 Jun 13, 2023
7565948
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 13, 2023
0f8f132
un comment routing error
techiealiraza Jun 13, 2023
62f5f9e
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 13, 2023
45b855e
remove unused code
techiealiraza Jun 13, 2023
30e9daa
Session controller fixed
techiealiraza Jun 13, 2023
23a5259
nested selection under the matches
progammer743 Jun 13, 2023
13c8925
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 13, 2023
e6a7369
js files refactoring
techiealiraza Jun 13, 2023
f9f9869
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 13, 2023
1fee544
fixed typo in touranment's form
progammer743 Jun 13, 2023
ab8f4c7
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 13, 2023
9a0677d
removed unused code from tailwind.config.js
progammer743 Jun 13, 2023
ac69b3f
use assets instead of online images in edit file of registration
progammer743 Jun 13, 2023
d0fe754
added routes paths in new of registration and session files
progammer743 Jun 13, 2023
405a2f6
replace all Sign in to Log in
progammer743 Jun 13, 2023
fe6bb12
fixed typo
progammer743 Jun 13, 2023
23102af
added validation in selection
progammer743 Jun 13, 2023
0baa2e3
fixes view issues show matches/tournaments
progammer743 Jun 13, 2023
e74bf13
views fixed
techiealiraza Jun 13, 2023
f4b6b42
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 13, 2023
d369859
session controller invalid password msg updated
progammer743 Jun 13, 2023
6e124f0
tournaments path and render fixed
techiealiraza Jun 13, 2023
74551ce
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 13, 2023
6db77ce
gwm file lock fixed
techiealiraza Jun 13, 2023
f19dcd3
updated Gemfile.lock and renamed broadcaster to action_cable_broadcaster
progammer743 Jun 13, 2023
a4fffae
Merge remote-tracking branch 'origin/develop_new' into develop_new
progammer743 Jun 13, 2023
58d64af
match scores fix
techiealiraza Jun 14, 2023
db3f218
Merge branch 'develop_new' of https://github.com/techiealiraza/rock-p…
techiealiraza Jun 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 7 additions & 28 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,27 @@ gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 5.0'
# Turbolinks makes navigating your web appliletter_openercation faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
gem 'letter_opener', group: :development

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false
gem 'redis', '~> 4.0'

gem 'bootstrap'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: %i[mri mingw x64_mingw]
end

group :development do
gem 'bullet', '~> 7.0'

gem 'delayed_job_web', '~> 1.4.4', require: 'delayed_job_active_record'
gem 'erb_lint', '~> 0.4.0'
gem 'htmlbeautifier', '~> 1.4'
gem 'letter_opener'
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
gem 'listen', '~> 3.3'
gem 'rack-mini-profiler', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
# gem 'spring'
end

group :test do
Expand All @@ -62,6 +52,7 @@ end
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

gem 'activestorage', '~> 6.1'

gem 'devise', '~> 4.9'

gem 'tailwindcss', '~> 0.1.1'
Expand All @@ -70,28 +61,16 @@ gem 'tailwindcss-rails', '~> 2.0'

gem 'devise-two-factor', '~> 4.0'

gem 'dotenv-rails'
gem 'rqrcode', '~> 2.1'

gem 'stimulus-rails'

gem 'hotwire-rails', '~> 0.1.3'

# gem "autoprefixer"

gem 'kaminari'
gem 'whenever', '~> 1.0'

gem 'cancancan', '~> 3.5'

gem 'attr_encrypted', '~> 3.1'

gem 'daemons'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ali -> Code Understanding


gem 'delayed_job_active_record'
gem 'delayed_job_web', '~> 1.4.4', require: 'delayed_job_active_record'

gem 'twilio-ruby', '~> 5.77'

gem 'erb_lint', '~> 0.4.0'

gem 'htmlbeautifier', '~> 1.4'
31 changes: 2 additions & 29 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ GEM
ast (2.4.2)
attr_encrypted (3.1.0)
encryptor (~> 3.0.0)
autoprefixer-rails (10.4.13.0)
execjs (~> 2)
bcrypt (3.1.18)
better_html (2.0.1)
actionview (>= 6.0)
Expand All @@ -78,10 +76,6 @@ GEM
bindex (0.8.1)
bootsnap (1.16.0)
msgpack (~> 1.2)
bootstrap (5.2.3)
autoprefixer-rails (>= 9.1.0)
popper_js (>= 2.11.6, < 3)
sassc-rails (>= 2.0.0)
builder (3.2.4)
bullet (7.0.7)
activesupport (>= 3.0.0)
Expand All @@ -97,8 +91,6 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
chronic (0.10.2)
chunky_png (1.4.0)
concurrent-ruby (1.2.2)
crass (1.0.6)
daemons (1.4.1)
Expand All @@ -125,10 +117,6 @@ GEM
devise (~> 4.0)
railties (< 7.1)
rotp (~> 6.0)
dotenv (2.8.1)
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
railties (>= 3.2)
encryptor (3.0.0)
erb_lint (0.4.0)
activesupport
Expand All @@ -138,7 +126,6 @@ GEM
rubocop
smart_properties
erubi (1.12.0)
execjs (2.8.1)
faraday (2.7.5)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
Expand All @@ -153,9 +140,6 @@ GEM
htmlbeautifier (1.4.2)
i18n (1.13.0)
concurrent-ruby (~> 1.0)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.6.3)
jwt (2.7.0)
kaminari (1.2.2)
Expand Down Expand Up @@ -212,7 +196,6 @@ GEM
parser (3.2.2.1)
ast (~> 2.4.1)
pg (1.5.3)
popper_js (2.11.7)
public_suffix (5.0.1)
puma (5.6.5)
nio4r (~> 2.0)
Expand Down Expand Up @@ -264,10 +247,6 @@ GEM
railties (>= 5.2)
rexml (3.2.5)
rotp (6.2.2)
rqrcode (2.2.0)
chunky_png (~> 1.0)
rqrcode_core (~> 1.0)
rqrcode_core (1.2.0)
rubocop (1.51.0)
json (~> 2.3)
parallel (~> 1.10)
Expand Down Expand Up @@ -304,6 +283,7 @@ GEM
rack-protection (= 3.0.6)
tilt (~> 2.0)
smart_properties (1.17.0)
spring (4.1.1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not updated version ?

sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
Expand Down Expand Up @@ -356,8 +336,6 @@ GEM
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
whenever (1.0.0)
chronic (>= 0.6.3)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.8)
Expand All @@ -368,9 +346,7 @@ PLATFORMS

DEPENDENCIES
activestorage (~> 6.1)
attr_encrypted (~> 3.1)
bootsnap (>= 1.4.4)
bootstrap
bullet (~> 7.0)
byebug
cancancan (~> 3.5)
Expand All @@ -380,11 +356,9 @@ DEPENDENCIES
delayed_job_web (~> 1.4.4)
devise (~> 4.9)
devise-two-factor (~> 4.0)
dotenv-rails
erb_lint (~> 0.4.0)
hotwire-rails (~> 0.1.3)
htmlbeautifier (~> 1.4)
jbuilder (~> 2.7)
kaminari
letter_opener
listen (~> 3.3)
Expand All @@ -393,9 +367,9 @@ DEPENDENCIES
rack-mini-profiler (~> 2.0)
rails (~> 6.1.7, >= 6.1.7.2)
redis (~> 4.0)
rqrcode (~> 2.1)
sass-rails (>= 6)
selenium-webdriver (>= 4.0.0.rc1)
spring
stimulus-rails
tailwindcss (~> 0.1.1)
tailwindcss-rails (~> 2.0)
Expand All @@ -405,7 +379,6 @@ DEPENDENCIES
web-console (>= 4.1.0)
webdrivers
webpacker (~> 5.0)
whenever (~> 1.0)

RUBY VERSION
ruby 3.1.3p185
Expand Down
8 changes: 8 additions & 0 deletions app/channels/match_channel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# channel for timer and selection
class MatchChannel < ApplicationCable::Channel
def subscribed
stream_from "match_channel_#{params[:match_id]}"
end
end
8 changes: 0 additions & 8 deletions app/channels/timer_channel.rb

This file was deleted.

7 changes: 4 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
class ApplicationController < ActionController::Base
protect_from_forgery prepend: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this ?

before_action :configure_permitted_parameters, if: :devise_controller?
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
rescue_from ActiveRecord::RecordNotFound, with: :not_found
rescue_from CanCan::AccessDenied, with: :access_denied
rescue_from ActionController::RoutingError, with: :not_found

def access_denied
render file: "#{Rails.root}/public/403.html", formats: [:html], status: 403, layout: false
end

def record_not_found
def not_found
render file: "#{Rails.root}/public/404.html", formats: [:html], status: 404, layout: false
end

Expand All @@ -26,7 +27,7 @@ def after_resetting_password_path_for(user)

def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: %i[name email password phone_number])
devise_parameter_sanitizer.permit(:account_update, keys: %i[name email password phone_number avatar])
devise_parameter_sanitizer.permit(:account_update, keys: %i[name email password phone_number image])
devise_parameter_sanitizer.permit(:sign_in, keys: [:otp_attempt])
end
end
2 changes: 1 addition & 1 deletion app/controllers/leaderboard_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LeaderBoard Controller
class LeaderboardController < ApplicationController
def index
@players = LeaderBoard.new.result
@players = LeaderBoardCreator.call
end
end
29 changes: 8 additions & 21 deletions app/controllers/matches_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

# Matches_Controller

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RESTFul Routes comments

index -> should have been a nested route tournaments/id/matches/

class MatchesController < ApplicationController
load_and_authorize_resource :tournament
load_and_authorize_resource through: :tournament
Expand All @@ -16,31 +15,19 @@ def all

def show; end

def new
@match = Match.new
end

def playmatch
@match = Match.includes([:users]).find(params[:match_id])
redirect_to result_tournament_match_path(match_id: @match) unless @match.match_winner_id.nil?
@players = @match.users
@remaining_tries = @match.remaining_tries(@players.first.id)
@done_tries = @match.selections.by_user(@players.first.id).size
@is_player = @match.users.include?(current_user)
@messages = @match.messages.includes([:user]).all.reverse
end
return if @match.done?

def result
@is_player = @match.users.include?(current_user)
@players = @match.users
@players_selections = @match.selections.order(:try_num).group_by(&:user_id)
@players_scores = @match.selections.group(:user_id).winner.count
@result_message = @match.result_message(current_user.id)
@players_data = @match.players_data_by_current_user(current_user)
end

private
def result
return if @match.undone?

def match_params
params.require(:match).permit(:match_winner_id, :winner_score, :match_time, :tournament_id)
@players_data = @match.players_data_by_current_user(current_user)
@players_selections = @match.selections.includes(:user).order(:try_num).group_by(&:user_id)
@players_scores = @match.selections.winner.group(:user_id).count
@result_message = @match.result_message(current_user.id)
end
end
18 changes: 6 additions & 12 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,20 @@

class MessagesController < ApplicationController
load_and_authorize_resource
def index; end

def new
@message = Message.new
end

def create
@message = Message.new(message_params)
respond_to do |format|
if @message.save
format.json { render json: { data: 'Saved' }, status: :ok }
else
format.json { render json: { errors: @message.errors.full_messages }, status: :unprocessable_entity }
end
@message.user_id = current_user.id
if @message.save
flash[:notice] = 'Message Sent'
else
flash[:error] = @message.errors.full_messages.join(', ')
end
end

private

def message_params
params.permit(:user_id, :match_id, :message)
params.permit(:match_id, :content)
end
end
19 changes: 7 additions & 12 deletions app/controllers/selection_controller.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
# frozen_string_literal: true

class SelectionController < ApplicationController
load_and_authorize_resource
before_action :authenticate_user!

def create
@selection = Selection.new(selection_params)
@selection.add_try_num
respond_to do |format|
if @selection.save
format.json { render json: { data: 'Saved' }, status: :ok }
else
format.json { render json: { errors: @selection.errors.full_messages }, status: :unprocessable_entity }
end
if @selection.save
flash[:notice] = 'Choice Saved'
else
flash[:error] = @selection.errors.full_messages.join(', ')
end
end

def new
@selection = Selection.new
end

private

def selection_params
params.require(:selection).permit(:match_id, :user_id, :selection)
params.require(:selection).permit(:match_id, :user_id, :choice)
end
end
Loading