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
This commit is contained in:
kbe
2025-08-30 19:03:29 +02:00
parent 476438c5c4
commit 6ea3005a65
38 changed files with 1151 additions and 297 deletions

View File

@@ -7,7 +7,6 @@ class CreateTicketTypes < ActiveRecord::Migration[8.0]
t.integer :quantity
t.datetime :sale_start_at
t.datetime :sale_end_at
t.boolean :requires_id
t.integer :minimum_age
t.references :event, null: false, foreign_key: false

View File

@@ -3,7 +3,7 @@ class CreateTickets < ActiveRecord::Migration[8.0]
create_table :tickets do |t|
t.string :qr_code
t.integer :price_cents
t.string :status, default: "active"
t.string :status, default: "draft"
# Add names to ticket
t.string :first_name

View File

@@ -9,20 +9,20 @@
# 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'
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)
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.password = "password"
u.password_confirmation = "password"
u.last_name = nil
u.first_name = nil
end
@@ -97,7 +97,6 @@ events.each_with_index do |event, index|
tt.quantity = 100
tt.sale_start_at = 1.month.ago
tt.sale_end_at = event.start_time - 1.hour
tt.requires_id = false
tt.minimum_age = 18
end
@@ -108,7 +107,6 @@ events.each_with_index do |event, index|
tt.quantity = 20
tt.sale_start_at = 1.month.ago
tt.sale_end_at = event.start_time - 1.hour
tt.requires_id = true
tt.minimum_age = 21
end
end