Last active
August 7, 2020 02:02
-
-
Save jordanbrock/b6fd00c727a2d6a33366554a57e5a7b1 to your computer and use it in GitHub Desktop.
Params deserialisation issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Represents a selection of a Player for a Match | |
class Selection < ApplicationRecord | |
acts_as_list scope: :match | |
belongs_to :match | |
belongs_to :player | |
# Ensure that the selections are returned in postition order | |
def self.default_scope | |
order(position: :asc) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To deliver this notification | |
# | |
# SelectionNotification.with(post: @post).deliver_later(current_user) | |
# SelectionNotification.with(post: @post).deliver(current_user) | |
class SelectionNotification < Noticed::Base | |
# Add your delivery methods | |
# | |
deliver_by :database | |
# deliver_by :email, mailer: "UserMailer" | |
# deliver_by :slack | |
# deliver_by :custom, class: "MyDeliveryMethod" | |
# Add required params | |
# | |
param :selection | |
# Define helper methods to make rendering easier. | |
# | |
# def message | |
# t(".message") | |
# end | |
# | |
# def url | |
# post_path(params[:post]) | |
# end | |
end |
Awesome stuff Chris. Trying it out now!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And in case you're interested, the solution was to serialize with ActiveJob's serializer, then serialize with JSON. Reverse on the way out.
Previously it was writing the string representation of the hash to the text column. We don't want to
eval
that to load it back out, so converting to JSON was safer and more compatible.