Files
aperonight/db/seeds.rb
kbe 6ea3005a65 feat: Implement complete ticket purchasing flow with new TicketsController
- Create new TicketsController with actions for name collection, creation, and checkout
- Add dedicated ticket views (new.html.erb, checkout.html.erb, show.html.erb)
- Update ticket_selection_controller.js to handle form submission via AJAX
- Add store_cart endpoint in EventsController for session-based cart management
- Update routes to support new ticket flow: /tickets/new, /create, /checkout
- Fix attribute name consistency across views (title→name, starts_at→start_time)
- Add Stripe checkout integration with proper error handling
- Remove deprecated collect_names flow in favor of streamlined approach

The flow is now: Event selection → AJAX cart storage → Name collection → Checkout → Payment
2025-08-30 20:03:34 +02:00

115 lines
3.9 KiB
Ruby
Executable File

# This file should ensure the existence of records required to run the application in every environment (production,
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Example:
#
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
# MovieGenre.find_or_create_by!(name: genre_name)
# end
# Create admin user for development
admin_user = User.find_or_create_by!(email: "admin@example.com") do |u|
u.password = "password"
u.password_confirmation = "password"
u.last_name = nil
u.first_name = nil
end
# Create regular users for development
users = User.where.not(email: "admin@example.com").limit(5)
missing_users_count = 5 - users.count
missing_users_count.times do |i|
User.find_or_create_by!(email: "user#{i + 1}@example.com") do |u|
u.password = "password"
u.password_confirmation = "password"
u.last_name = nil
u.first_name = nil
end
end
# Reload all users after creation
users = User.all.to_a
# Create sample events
events_data = [
{
name: "Summer Beach Event",
slug: "summer-beach-event",
description: "Join us for an amazing night at the beach with music, dancing, and cocktails.",
venue_name: "Sunset Beach Resort",
venue_address: "123 Ocean Drive, Miami, FL",
latitude: 25.7617,
longitude: -80.1918,
start_time: 1.day.from_now,
end_time: 1.day.from_now + 6.hours,
featured: true,
image: "https://fastly.picsum.photos/id/407/300/200.jpg?hmac=9EhoXMZ1QdwJue90vzxcjBg2YzsZsAWCjJ7oxOhtcU0",
user: users.first
},
{
name: "Rooftop Jazz Night",
slug: "rooftop-jazz-night",
description: "Experience smooth jazz under the stars at our exclusive rooftop venue.",
venue_name: "Skyline Rooftop Bar",
venue_address: "456 Downtown Ave, New York, NY",
latitude: 40.7128,
longitude: -74.0060,
start_time: 3.days.from_now,
end_time: 3.days.from_now + 4.hours,
featured: true,
image: "https://images.unsplash.com/photo-1511671782779-c97d3d27a1d4?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80",
user: users.second
},
{
name: "Warehouse Electronic Festival",
slug: "warehouse-electronic-festival",
description: "A night of electronic music and dancing in an industrial warehouse setting.",
venue_name: "Downtown Warehouse",
venue_address: "789 Industrial Blvd, Los Angeles, CA",
latitude: 34.0522,
longitude: -118.2437,
start_time: 1.week.from_now,
end_time: 1.week.from_now + 8.hours,
featured: false,
image: "https://images.unsplash.com/photo-1470225620780-dba8ba36b745?ixlib=rb-4.0.3&auto=format&fit=crop&w=800&q=80",
user: users.third
}
]
events = []
events_data.each do |event_data|
user = event_data.delete(:user)
event = Event.find_or_create_by!(name: event_data[:name]) do |p|
p.assign_attributes(event_data)
p.user = user
p.state = :published
end
events << event
end
# Create ticket types for each event
events.each_with_index do |event, index|
# General Admission ticket type
TicketType.find_or_create_by!(event: event, name: "General Admission") do |tt|
tt.description = "General admission ticket for #{event.name}"
tt.price_cents = 2500 # $25.00
tt.quantity = 100
tt.sale_start_at = 1.month.ago
tt.sale_end_at = event.start_time - 1.hour
tt.minimum_age = 18
end
# VIP ticket type
TicketType.find_or_create_by!(event: event, name: "VIP") do |tt|
tt.description = "VIP access ticket for #{event.name} with premium benefits"
tt.price_cents = 7500 # $75.00
tt.quantity = 20
tt.sale_start_at = 1.month.ago
tt.sale_end_at = event.start_time - 1.hour
tt.minimum_age = 21
end
end
puts "Created #{User.count} users, #{Event.count} events, and #{TicketType.count} ticket types"