-
-
Save jordanbrock/b6fd00c727a2d6a33366554a57e5a7b1 to your computer and use it in GitHub Desktop.
# 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 |
# 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 |
Yeah, I mean I want to support sqlite and MySQL so we definitely need support for text columns.
Maybe we can detect the column type or we can make it a config option. I'm not real sure.
Fixed! Thanks for the heads up on this ๐
As it turns out, my test suite was still using a jsonb column and I thought I had changed that. I've added tests for text
, json
and jsonb
column types now so we can know it'll work for them all now.
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.
Awesome stuff Chris. Trying it out now!
๐