Just launched! Get 30% off Rails Revisited Have a Look

Defining Parts of a Page

Buy or Subscribe

You can access this course in just a minute, and support my efforts to rid the world of crappy online courses!

Buy Standalone  Subscribe

A Part in Spina is a singular piece of content that goes into building a Page. It can be one line of text, many lines, rich text, images, and so on. You can actually create your very own parts, which I'm not going to do in this production.
Defining a part in Spina is a matter of giving it a name, description, and part definition:
# config/initializers/theme/default.rb
theme.parts = [
  {name: 'body',  title: "Body",  part_type: "Spina::Parts::Text"}, 
  {name: 'summary',  title: "Summary",  part_type: "Spina::Parts::Text"}, 
  #...
]
Once you have your parts declared, you can use them with a Page:
theme.view_templates = [
  {name: 'homepage', title: 'Homepage', parts: %w(summary body)}, 
  {name: 'show',     title: 'Page',     parts: %w(summary body)},
  #...
]

The CMS Dance

Each page should have a purpose in your application that makes sense. In my case, I have a dedicated Sales page as well as Courses, Course, and Lesson. Each of these pages has its own content needs, and each of them is displayed on a dedicated view template.
Half the trick of working with a CMS is understanding how to assemble the moving parts into something that makes sense to you and your team and, thankfully, Spina is pretty low in terms of concept count.