README.md in cadmus-0.6.0 vs README.md in cadmus-0.7.0
- old
+ new
@@ -1,8 +1,8 @@
# Cadmus: an embeddable CMS for Rails
-Cadmus is an embeddable content management system for Rails 3 applications. It's based on [Liquid](http://liquidmarkup.org)
+Cadmus is an embeddable content management system for Rails applications. It's based on [Liquid](http://liquidmarkup.org)
and is designed to be small and unobtrusive.
Cadmus doesn't define controllers or models itself, but rather, provides mixins to add CMS-like functionality to controllers
and models you create. This allows a great deal of customization. For example, Cadmus doesn't provide any user authentication
or authorization functionality, but because it hooks into controllers in your app, you can add virtually any authorization
@@ -36,56 +36,27 @@
```ruby
add_index :pages, [:parent_type, :parent_id, :slug], :unique => true
```
-And in the model, add a `cadmus_page` declaration:
+And in the model, include `Cadmus::Page` and add a `cadmus_page` declaration:
```ruby
class Page < ActiveRecord::Base
+ include Cadmus::Page
cadmus_page
end
```
You'll need a controller to deal with your pages. Here's a minimal example of one:
```ruby
class PagesController < ApplicationController
include Cadmus::PagesController
-
- protected
- def page_class
- Page
- end
end
```
-If you're on Rails 4 (or using the `strong_parameters` gem) you'll probably want to use forbidden attributes protection.
-Here's how you do that:
-
-```ruby
-class Page < ActiveRecord::Base
- include ActiveModel::ForbiddenAttributesProtection
- cadmus_page
-end
-```
-
-```ruby
-class PagesController < ApplicationController
- include Cadmus::PagesController
-
- protected
- def page_params
- params.require(:page).permit(:name, :slug, :content)
- end
-
- def page_class
- Page
- end
-end
-```
-
`Cadmus::PagesController` automatically adds the seven RESTful resource methods to your controller. It requires that you
define a `page_class` method that returns the class for pages it's dealing with. (This could potentially return different
classes depending on request parameters, if you need it to - or, you could also set up different controllers for different
types of page.)
@@ -305,11 +276,11 @@
Cadmus provides a convenience mixin to let you make that field a Liquid template. You can use it like so:
```ruby
class WelcomeEmail < ActiveRecord::Base
- include Cadmus::LiquidTemplateField
+ include Cadmus::Concerns::LiquidTemplateField
liquid_template_field :content_liquid_template, :content
belongs_to :team
end
@@ -317,11 +288,11 @@
Now if you call `my_welcome_email.content_liquid_template`, you'll get a parsed `Liquid::Template` generated from the value of `my_welcome_email.content`. You could further make the WelcomeEmail into a `Cadmus::Renderable` to make it render the template:
```ruby
class WelcomeEmail < ActiveRecord::Base
- include Cadmus::LiquidTemplateField
+ include Cadmus::Concerns::LiquidTemplateField
include Cadmus::Renderable
liquid_template_field :content_liquid_template, :content
belongs_to :team
@@ -334,10 +305,10 @@
Presto! Now you can call `my_welcome_email.rendered_content`. Since `WelcomeEmail` includes `Cadmus::Renderable`, you can also define `liquid_assigns` to expose variables to the template, for example:
```ruby
class WelcomeEmail < ActiveRecord::Base
- include Cadmus::LiquidTemplateField
+ include Cadmus::Concerns::LiquidTemplateField
include Cadmus::Renderable
liquid_template_field :content_liquid_template, :content
belongs_to :team