Contentment

Contentment is a extremely basic Content Management System for Ruby On Rails.

How often do your clients want to manage / edit some piddly little portion of the site you’re building for them? Every time? Yeah me too. If what you need is a way for your clients to manage the FAQ or Testimonials, contentment is for you. It’s simple to use and will save you time.

The primary advantage it offers over a roll-your-own CMS is consistency. Use Contentment whenever you need a basic CMS and you can stop re-inventing the wheel and start pumping code.

Get Contentment

Add it to your gemfile gem ‘contentment’ and run bundle install

Use Contentment

rails generate contentment rails g contentment_views rake db:migrate This will create the Content model and a migration to add the contents table to your database, if it doesn’t already exist. It will also create contents_controller.rb for you with all the CRUD already done, and create the views to manage your Content.

add

resources :contents

to your routes.rb file and you’re ready to go.

Details

:title and :body are pretty self explanatory, perfect for question and answer, or header and paragraph.

:tipe is not type to get around rails polymorphic associations, and exists to help you keep track of what Content goes on what pages. Add your own values to the @tipes array

  @tipes = [
	# "Billboard",
	# "What You Learn",
	# "Tips",
	# "Questions Copy",
	# "FAQ",
	# "Examples",
	# "Testimonial",
	# "Navigation",
	]

and you’ll get things like Content.for_faq or Content.for_navigation. Be careful about changing tipes after you’ve been up and running for a while or you might orphan Content.

:dom_id is rarely used, but sometimes you need to manipulate Content on the page with JavaScript and this is there for that.

:position will help you control the order of things in lists.

:visible will help you hide things without deleting them.

:link will allow you to have your navigation editable by your client. Put what you want to show up in the title, and where you want to go in the link field and I’m sure you can fill in the rest.

Live Preview of Content on Edit

I’ve added tinymce-rails as a dependency of this project. TinyMCE is nice because your clients probably want the ability to add line breaks and other styling without having to learn HTML.

If you’re using jQuery you should be able to see the changes made to the title and body of your content on the edit view live and in real time in the preview area. Clients (usually) love that.

That’s It!

If it did anything else it wouldn’t be simple anymore.

Questions, Thoughts, Comments to [email protected]

Thanks

A thousand thanks to @modestrubyist from www.themodestrubyist.com/ , without whose tutorials on the subject of Rails 3 Engines I would be nowhere.

Also thanks to the thoughtbot team and the clearance gem, which I looked at to learn more. github.com/thoughtbot/clearance

And also finally thanks to github.com/elricstorm/baby_dove which I used as a template for this whole engine.

Read More about engines - edgeapi.rubyonrails.org/classes/Rails/Engine.html

Write your own gemspec - blog.leshill.org/blog/2011/08/21/write-your-own-gemspec.html

Rubygems guide to building your own gem - guides.rubygems.org/make-your-own-gem/

TODO

* Get an example app using contentment up somewhere to show it off.