Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
[fix] wrong fix
Browse files Browse the repository at this point in the history
the problem were not in the positioning gem code but in bad seed data. [see here](brendon/positioning#5),
When a record changes, positioning store it temporarily with position=0 which were conflicting with the position assigned to another record during seeding.
  • Loading branch information
multiscan committed May 15, 2024
1 parent b3e727a commit 0f4588e
Show file tree
Hide file tree
Showing 17 changed files with 106 additions and 91 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ WORKDIR $APP_HOME
# RUN yarn cache clean && yarn install --verbose --modules-folder $MODULES_PATH

ADD Gemfile* $APP_HOME/
ADD ./.gems $APP_HOME/.gems
RUN ls -l
ADD bin/bundle $APP_HOME/bin/bundle
RUN ./bin/bundle
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ gem 'paper_trail', '~> 14'
# https://github.com/brendon/positioning
# gem 'positioning'
# TODO: temporary workaround, check https://github.com/brendon/positioning/pulls
gem 'positioning', path: ".gems/positioning"
gem 'positioning'

# Avoid a warning message from rubyzip about broken compatibility of >=3.0
# TODO: recheck if this is still the case
Expand Down
12 changes: 4 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
PATH
remote: .gems/positioning
specs:
positioning (0.2.1)
activerecord (>= 6.1)
activesupport (>= 6.1)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -201,6 +194,9 @@ GEM
parser (3.3.1.0)
ast (~> 2.4.1)
racc
positioning (0.2.1)
activerecord (>= 6.1)
activesupport (>= 6.1)
prime (0.1.2)
forwardable
singleton
Expand Down Expand Up @@ -373,7 +369,7 @@ DEPENDENCIES
jbuilder
mysql2
paper_trail (~> 14)
positioning!
positioning
prime (~> 0.1.2)
puma (>= 5.0)
rails (~> 7.1.3, >= 7.1.3.2)
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ shell: dcup
dbconsole: dcup
docker compose exec mariadb mariadb -u root --password=mariadb

## attach the console of the rails app for debugging
.PHONY: debug
debug:
docker-compose attach webapp

dconfig:
docker compose config

Expand Down
1 change: 1 addition & 0 deletions app/models/award.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Award < ApplicationRecord
include AudienceLimitable
include Translatable
translates :title
positioned on: :profile

validates :issuer, presence: true
validates :year, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/audience_limitable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module AudienceLimitable
scope :intranet_visible, -> { where(visible: true, audience: 0...1) }
scope :auth_visible, -> { where(visible: true) }
scope :for_audience, ->(audience) { where(visible: true, audience: 0...audience) }
validates :audience, numericality: { in: 0...2 }
validates :audience, numericality: { in: 0...5 }
end

def world_visible?
Expand Down
1 change: 1 addition & 0 deletions app/models/education.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Education < ApplicationRecord
include Translatable

belongs_to :profile
positioned on: :profile

translates :title, :field

Expand Down
3 changes: 2 additions & 1 deletion app/models/experience.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ class Experience < ApplicationRecord
include Translatable

belongs_to :profile

# broadcasts_to :profile

positioned on: :profile

translates :title, :field
translates_rich_text :description

Expand Down
1 change: 1 addition & 0 deletions app/models/social.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Social < ApplicationRecord
}.freeze

belongs_to :profile, class_name: "Profile", inverse_of: :socials
positioned on: :profile

validates :value, presence: true
validates :tag, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/views/experiences/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<div class="row justify-content-center">
<%= expform.submit t(experience.new_record? ? 'action.create_experience' : 'action.update_experience'), class: "btn btn-secondary btn-sm" %>
<%= link_to(t('cancel'), experience_path(experience), class: "btn btn-secondary btn-sm", method: :get, data: {turbo_stream: true, turbo_method:'get'}) if cancel.present? %>
<%= link_to(t('cancel'), experience_path(experience), class: "btn btn-secondary btn-sm", method: :get, data: {turbo_stream: true, turbo_method:'get'}) unless experience.new_record? %>
</div>
<% end %>
6 changes: 3 additions & 3 deletions bin/docker-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
BUNDLE_PATH=${BUNDLE_PATH:-vendor/bundle}

# If running the rails server then create or migrate existing database
if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
./bin/rails db:prepare
fi
# if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
# ./bin/rails db:prepare
# fi

exec "${@}"
Loading

0 comments on commit 0f4588e

Please sign in to comment.