fix: Add slug column to parties table and update seed data
- Added slug column to parties table via migration - Updated seed data to properly assign slug values to Party records - Fixed NoMethodError when assigning slug attribute in seed file This resolves the ActiveModel::UnknownAttributeError that occurred when trying to set the slug attribute on Party model instances.
This commit is contained in:
@@ -21,6 +21,7 @@ class Party < ApplicationRecord
|
||||
# Validations for party attributes
|
||||
# Basic information
|
||||
validates :name, presence: true, length: { minimum: 3, maximum: 100 }
|
||||
validates :slug, presence: true, length: { minimum: 3, maximum: 100 }
|
||||
validates :description, presence: true, length: { minimum: 10, maximum: 1000 }
|
||||
validates :state, presence: true, inclusion: { in: states.keys }
|
||||
validates :image, length: { maximum: 500 } # URL or path to image
|
||||
@@ -43,7 +44,8 @@ class Party < ApplicationRecord
|
||||
scope :featured, -> { where(featured: true) } # Get featured parties for homepage
|
||||
scope :published, -> { where(state: :published) } # Get publicly visible parties
|
||||
scope :search_by_name, ->(query) { where("name ILIKE ?", "%#{query}%") } # Search by name (case-insensitive)
|
||||
|
||||
|
||||
# Scope for published parties ordered by start time
|
||||
scope :upcoming, -> { published.where("start_time >= ?", Time.current).order(start_time: :asc) }
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user