Skip to content

Instantly share code, notes, and snippets.

@anitagraham
Created February 11, 2021 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anitagraham/b8e5fe716b6a9db7253af022fe2ef82d to your computer and use it in GitHub Desktop.
Save anitagraham/b8e5fe716b6a9db7253af022fe2ef82d to your computer and use it in GitHub Desktop.
Spina Custom Part
-# app/views/spina/admin/parts/cards/_form.html.haml
.page-form-label= f.object.title
.page-form-control
# this line, as generated, produces "uninitialized constant Card"
.select-dropdown= f.select :card_id, Card.all.pluck(:title, :id)
# this line, with the model class in full gets "ActionView::Template::Error (undefined method `all' for Spina::Parts::Card:Class)"
.select-dropdown= f.select :card_id, Spina::Parts::Card.all.pluck(:title, :id)
module Spina
module Parts
class Card < Base
attr_json :card_id, :integer
attr_json :card_title, Spina::Parts::Line.to_type
attr_json :content, Spina::Parts::Text.to_type
attr_json :image, Spina::Parts::Image.to_type
attr_json :footer, Spina::Parts::Line.to_type
def content
Card.find(card_id)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment