# Controller for static pages and user dashboard # Handles basic page rendering and user-specific content class PagesController < ApplicationController # Skip authentication for public pages # skip_before_action :authenticate_user!, only: [ :home ] before_action :authenticate_user!, only: [ :dashboard ] # Homepage showing featured events def home # @events = Event.published.featured.limit(3) # @events = Event.where(state: :published).order(created_at: :desc) if user_signed_in? return redirect_to(dashboard_path) end end # User dashboard showing personalized content # Accessible only to authenticated users def dashboard @available_events = Event.published.count @events_this_week = Event.published.where("start_time BETWEEN ? AND ?", Date.current.beginning_of_week, Date.current.end_of_week).count @today_events = Event.published.where("DATE(start_time) = ?", Date.current).order(start_time: :asc) @tomorrow_events = Event.published.where("DATE(start_time) = ?", Date.current + 1).order(start_time: :asc) @other_events = Event.published.upcoming.where.not("DATE(start_time) IN (?)", [Date.current, Date.current + 1]).order(start_time: :asc).page(params[:page]) end # Events page showing all published events with pagination def events @events = Event.published.order(created_at: :desc).page(params[:page]) end end