Skip to content

Commit

Permalink
Fix parameter links
Browse files Browse the repository at this point in the history
Safer code in serializer
  • Loading branch information
balen committed Nov 30, 2023
1 parent 49d2d0f commit 1581d23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/schedule_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ScheduleController < ApplicationController
# end

def index
links = params.permit(:links)
links = params.permit(:links)[:links]

serializer = links ? Conclar::SessionSerializerWithLinks : Conclar::SessionSerializer
sessions = SessionService.scheduled_sessions
Expand Down
6 changes: 5 additions & 1 deletion app/serializers/conclar/session_serializer_with_links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class Conclar::SessionSerializerWithLinks < ActiveModel::Serializer
end

attribute :desc do
"#{object.description}<p><a href=\"#{object.integrations.dig('smofcon', 'link')}\" target=\"_blank\">Click here to view</a></p>"
if object.integrations
"#{object.description}<p><a href=\"#{object.integrations.dig('smofcon', 'link')}\" target=\"_blank\">Click here to view</a></p>"
else
object.description
end
end

attribute :datetime do
Expand Down

0 comments on commit 1581d23

Please sign in to comment.