-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introducing: cms_manageable #409
Conversation
Rails apps that use the cms_acts_as_cms extension need to have an explicit class_name set, otherwise, they assume the wrong namespace.
This helps with form builders for the cms_acts_as_cms extension
Amazing. This calls for a 1.12.0 release. Few things that spring to mind:
|
This is fucking great! May I suggest another name for the extension? cms_manageable instead of cms_acts_as_cms. |
|
it's not enterprisey enough |
|
+1 cms_manageable |
|
p = self.block.page | ||
Cms::Page.where(:id => p.id).update_all(:content => nil) | ||
p = self.block.blockable | ||
p.class.name.constantize.where(:id => p.id).update_all(:content => nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p
used to stand for page
@GBH - Just pushed some cleanup here. |
Feels. |
Have you ever been working on a project and wanted to treat one of your existing models just like a Cms::Page object?
At first this might sound bizarre, but I assure you, the use case is real, awesome, and actually has minimal impact on the comfy codebase. Let's take a moment to think this through....
Anyone who knows Comfy understands that its real benefit comes from layouts, tags, and blocks. Writing a layout that generates a dynamic form is a huge time saver and there have been a number of occasions where I've wanted the magic of Comfy mixed into my boring old Rails models. So with this in mind, I'd like to introduce cms_manageable.
What Does It Do?
Let's start with a boring old rails model:
So hey, let's spice things up by adding in the
cms_manageable
behaviour. The only requirements are that we provide alayout
method that returns a proper Comfy layout and add acontent
column on the model. Once you've done this, the benefits are clear:c'est bon, non?
But Why?
The possibilities are endless. Blocks. Layouts. Revisions. Rendering. Form Builders. Etc...
But How?
Cms::Blocks
are now polymorphic. Mind == Blown.What About Forms?
Ahhh, yes. Let's use some of those sweet sweet Comfy forms. Obviously the context of this code is within your admin area: