Creating a contentable does not create its associated content, so a contentable is not guaranteed to have content. Pass a contentable to
find_or_create its associated content. The following examples use a content page as the contentable.
# Create a content page page = Workarea::Content::Page.create!(name: 'Shopping Guide') # No content yet page.content # => nil # Create content for the page content = Workarea::Content.for(page) content.id.to_s # => "58ac8489eefbfe3e5ac2ae58" # Access the content from the page page.reload page.content.id.to_s # => "58ac8489eefbfe3e5ac2ae58" # Access the page from the content content.contentable_type # => "Workarea::Content::Page" content.contentable_id.to_s # => "58ac8489eefbfe3e5ac2ae56" content.contentable.name # => "Shopping Guide"
How'd We Do?
Was this article missing something?
Was it not quite what you were looking for?
Do you have suggestions on how we could improve this article or your experience in general?
If so, please take a moment to let us know!
Your invaluable feedback will help everyone better understand the platform!