develop #3

Merged
kbe merged 227 commits from develop into main 2025-09-16 14:35:23 +00:00
3 changed files with 36 additions and 3 deletions
Showing only changes of commit 0ba6634e99 - Show all commits

View File

@@ -256,6 +256,38 @@ events = Event.create!([...])
ticket_types = TicketType.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 ## 📝 Code Style & Conventions
- **Ruby Style**: Follow Rails conventions and Rubocop rules - **Ruby Style**: Follow Rails conventions and Rubocop rules
@@ -263,5 +295,6 @@ ticket_types = TicketType.create!([...])
- **JavaScript**: Stimulus controllers for interactive behavior - **JavaScript**: Stimulus controllers for interactive behavior
- **CSS**: Tailwind utility classes with custom components - **CSS**: Tailwind utility classes with custom components
- **Documentation**: Inline comments for complex business logic - **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. This architecture provides a solid foundation for a scalable ticket selling platform with proper separation of concerns, security, and user experience.

View File

@@ -4,7 +4,7 @@
# complete their details and proceed to payment # complete their details and proceed to payment
class TicketsController < ApplicationController class TicketsController < ApplicationController
before_action :authenticate_user!, only: [ :new, :payment_success, :payment_cancel ] 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 # Handle new ticket creation
# #
@@ -87,7 +87,7 @@ class TicketsController < ApplicationController
if success if success
session[:draft_order_id] = @order.id session[:draft_order_id] = @order.id
session.delete(:pending_cart) session.delete(:pending_cart)
redirect_to order_checkout_path(@order) redirect_to checkout_order_path(@order)
else else
redirect_to ticket_new_path(@event.slug, @event.id) redirect_to ticket_new_path(@event.slug, @event.id)
end end

View File

@@ -36,7 +36,7 @@
<% if event.featured? %> <% if event.featured? %>
<span class="badge badge-featured">★ En vedette</span> <span class="badge badge-featured">★ En vedette</span>
<% end %> <% end %>
<% if event.tickets.any? { |ticket| ticket.quantity > 0 } %> <% if event.ticket_types.any? { |ticket_type| ticket_type.available_quantity > 0 } %>
<span class="badge badge-available">Disponible</span> <span class="badge badge-available">Disponible</span>
<% end %> <% end %>
</div> </div>