diff --git a/AGENT.md b/AGENT.md index de9e238..6a2fdb1 100755 --- a/AGENT.md +++ b/AGENT.md @@ -256,6 +256,38 @@ events = Event.create!([...]) ticket_types = TicketType.create!([...]) ``` +## 🛠️ Available Development Tools + +### AST-Grep for Mass Code Replacement + +The system has `ast-grep` installed for structural code search and replacement. This tool is particularly useful for: + +- **Mass refactoring**: Rename methods, classes, or variables across the codebase +- **Pattern-based replacements**: Update code patterns using AST matching +- **Language-aware transformations**: Safer than regex for code modifications + +#### Usage Examples: + +```bash +# Find all method calls to a specific method +ast-grep --pattern 'find_by_$FIELD($VALUE)' --lang ruby + +# Replace method calls with new syntax +ast-grep --pattern 'find_by_$FIELD($VALUE)' --rewrite 'find_by($FIELD: $VALUE)' --lang ruby + +# Search for specific Rails patterns +ast-grep --pattern 'validates :$FIELD, presence: true' --lang ruby + +# Mass rename across multiple files +ast-grep --pattern 'old_method_name($$$ARGS)' --rewrite 'new_method_name($$$ARGS)' --lang ruby --update-all +``` + +#### Best Practices: +- Always run with `--dry-run` first to preview changes +- Use `--lang ruby` for Ruby files to ensure proper AST parsing +- Test changes in a branch before applying to main codebase +- Particularly useful for Rails conventions and ActiveRecord pattern updates + ## 📝 Code Style & Conventions - **Ruby Style**: Follow Rails conventions and Rubocop rules @@ -263,5 +295,6 @@ ticket_types = TicketType.create!([...]) - **JavaScript**: Stimulus controllers for interactive behavior - **CSS**: Tailwind utility classes with custom components - **Documentation**: Inline comments for complex business logic +- **Mass Changes**: Use `ast-grep` for structural code replacements instead of simple find/replace This architecture provides a solid foundation for a scalable ticket selling platform with proper separation of concerns, security, and user experience. \ No newline at end of file diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 2deee6a..2ccd1e9 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -4,7 +4,7 @@ # complete their details and proceed to payment class TicketsController < ApplicationController before_action :authenticate_user!, only: [ :new, :payment_success, :payment_cancel ] - before_action :set_event, only: [ :new ] + before_action :set_event, only: [ :new, :create ] # Handle new ticket creation # @@ -87,7 +87,7 @@ class TicketsController < ApplicationController if success session[:draft_order_id] = @order.id session.delete(:pending_cart) - redirect_to order_checkout_path(@order) + redirect_to checkout_order_path(@order) else redirect_to ticket_new_path(@event.slug, @event.id) end diff --git a/app/views/pages/home.html.erb b/app/views/pages/home.html.erb index f35fb72..9f6979a 100755 --- a/app/views/pages/home.html.erb +++ b/app/views/pages/home.html.erb @@ -36,7 +36,7 @@ <% if event.featured? %> ★ En vedette <% end %> - <% if event.tickets.any? { |ticket| ticket.quantity > 0 } %> + <% if event.ticket_types.any? { |ticket_type| ticket_type.available_quantity > 0 } %> Disponible <% end %>