Commit graph

16 commits

Author SHA1 Message Date
Claude
429f90e666
Refactor: Apply Rails best practice for early returns
Follow Rails convention of using "render/redirect ... and return"
instead of standalone return statements in controller actions.

## Changes

**Shared::TripsController#show**
Before:
```ruby
unless @trip&.public_accessible?
  return redirect_to root_path, alert: '...'
end
```

After:
```ruby
redirect_to root_path, alert: '...' and return unless @trip&.public_accessible?
```

**TripsController#update**
Before:
```ruby
if params[:sharing]
  return update_sharing
end
```

After:
```ruby
update_sharing and return if params[:sharing]
```

## Benefits
- More idiomatic Rails code
- Clearer intent with single-line guard clauses
- Prevents potential double render issues
- Follows community best practices
2025-11-07 11:49:05 +00:00
Claude
9fba3ce4ca
Refactor: Move trip sharing management to trips#update
Simplifies architecture by using the existing trips#update route for
sharing settings management instead of a separate route.

## Changes

**Routes**
- Removed: PATCH /trips/:id/sharing → shared/trips#update
- Now uses: PATCH /trips/:id (existing route) with sharing params

**Controllers**
- Shared::TripsController: Simplified to only handle public view (show)
- TripsController: Added update_sharing private method to handle
  sharing params when present

**Views**
- Updated JavaScript in _sharing.html.erb to use trip_path with
  nested sharing params

**Tests**
- Updated request specs to use trip_path instead of sharing_trip_path
- All params now nested under sharing key

## Benefits
- Cleaner namespace separation (Shared:: only for public access)
- Follows Rails conventions (one update route handles everything)
- Simpler routing structure
- Reduced code duplication

## Backwards Compatibility
This is a breaking change for the sharing API endpoint, but since
this feature was just implemented and hasn't been released yet,
no migration path is needed.
2025-11-05 15:54:42 +00:00
Eugene Burmakin
57ecda2b1b Extract stats sharing logic to its own controller 2025-09-12 21:08:45 +02:00
Eugene Burmakin
6defd4d8d0 Update distance unit in trip page 2025-05-19 19:10:07 +02:00
Eugene Burmakin
c69d4f45f1 Update views and specs 2025-05-16 19:53:42 +02:00
Eugene Burmakin
96108b12d0 Update tests a bit 2025-05-15 22:58:04 +02:00
Eugene Burmakin
088d8b14c2 Calculate trip data in the background 2025-05-15 21:33:01 +02:00
Eugene Burmakin
6fac14675b Restrict to some functionality access for inactive users 2025-02-19 21:23:11 +01:00
Eugene Burmakin
1e7efbc9af Render trips using precalculated paths instead of list of coordinates 2025-01-24 14:54:10 +01:00
Eugene Burmakin
d6b88ae9cb Move photos fetching for trips to a separate service 2024-12-10 19:31:52 +01:00
Eugene Burmakin
782aeb89af Add distance calculation and trip cards to trips index 2024-11-28 15:29:17 +01:00
Eugene Burmakin
e8842a9476 Implement rendering the route when the dates if the trip are changed 2024-11-28 13:20:03 +01:00
Eugene Burmakin
2cfc485f12 Add Trix editor to trips 2024-11-28 12:00:54 +01:00
Eugene Burmakin
c689051472 Show some photos from the trip 2024-11-28 10:40:08 +01:00
Eugene Burmakin
9522f81abf Move fetchAndDisplayPhotos to maps/helpers.js 2024-11-27 21:37:21 +01:00
Eugene Burmakin
198bf3128a Add trips model and scaffold controller 2024-11-27 20:14:17 +01:00