Sha256: c14e726cfcf0f3707d557200e1117ff6fb1db0e794144dc7f970f88ed9e71166
Contents?: true
Size: 910 Bytes
Versions: 12
Compression:
Stored size: 910 Bytes
Contents
class PostResource < Avo::BaseResource # tutorial (title): https://youtu.be/WgNK-oINFww?t=301 self.title = :title # tutorial (n+1): https://youtu.be/WgNK-oINFww?t=557 self.includes = [:category] # tutorial (search): https://youtu.be/WgNK-oINFww?t=244 self.search_query = ->(params:) do scope .ransack(id_eq: params[:q], title_cont: params[:q], m: "or") .result(distinct: false) end # tutorial (edit fields): https://youtu.be/WgNK-oINFww?t=133 field :id, as: :id field :title, as: :text field :content, as: :trix # tutorial (read only fields): https://youtu.be/WgNK-oINFww?t=228 field :excerpt, as: :text, only_on: :index # tutorial (related category): https://youtu.be/WgNK-oINFww?t=328 field :category, as: :belongs_to # tutorial (related category with custom name): https://youtu.be/WgNK-oINFww?t=722 field :user, name: "Author", as: :belongs_to end
Version data entries
12 entries across 12 versions & 1 rubygems