Skip to content

Commit

Permalink
Minor Refactor - Validation helpers on Event (#225)
Browse files Browse the repository at this point in the history
* Updating to use two validation helpers so I can screenshot it for my talk.

* Turn off Rails/Validation which doesn't like validation helpers. They don't include comparison. :( https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsvalidation
ChaelCodes authored May 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 4f19d24 commit 8fcef40
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -50,6 +50,9 @@ Naming/BlockForwarding:
Rails/RequestReferer:
EnforcedStyle: referrer

Rails/Validation:
Enabled: false

RSpec/ExampleLength:
Max: 10

2 changes: 1 addition & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ class Event < ApplicationRecord
has_many :event_attendees, dependent: :delete_all
has_many :attendees, through: :event_attendees, source: :profile

validates :start_at, :end_at, presence: true
validates_presence_of :start_at, :end_at
validates_comparison_of :end_at, greater_than: :start_at

scope :ongoing_or_upcoming, -> { where("end_at >= ?", Time.zone.now) }

0 comments on commit 8fcef40

Please sign in to comment.