Tada! Comatose _finally_ supports Rails 1.2!
In fact, it *only* supports Rails 1.2 now. If you are still on Rails 1.1, **don’t** upgrade Comatose — It won’t work. Consider yourself warned. ([version 0.7.1][] is tagged, so all you Rails 1.1ers can still get to it)
OK, so I made quite a few changes whilst upgrading Comatose. No functionality was removed, yet, but enough has changed that we should hit the high points here… I’ll post a more in-depth article on the [dev blog][] later.
First up, there’s a **new configuration system**. It’s quite dandy, really. It single-handedly made the `DEFER_COMATOSE_LOAD` and controller class hacking _obsolete_.
You can still use all the same old settings, only you set them in a configuration block in your `environment.rb` now. Here’s an example from an app I’m currently working on:
Comatose.configure do |comatose|
comatose.includes << :authenticated_system
comatose.helpers << :application_helper
# admin
comatose.admin_title = “My App’s CMS”
comatose.admin_sub_title = “… its’ fun for the whole family!”
comatose.admin_includes << :authenticated_system
comatose.admin_helpers << :application_helper
comatose.admin_authorization = :admin_required
comatose.default_tree_level = 1
comatose.admin_get_author do
current_user.login
end
comatose.admin_get_root_page do
roots = %w(public-root content-fragments)
roots.collect {|path| Comatose::Page.find_by_path(path)}
end
end
Look over that example closely, there’s a lot hidden in there.
* `comatose.includes` is an array of module names (as symbols) that will be included in the `ComatoseController`.
* `comatose.helpers` is also an array of module names, only these are loaded as [helpers][] so you can use them in a view, most likely in your layout.
Remember, you **no longer extend `ComatoseController`** to add functionality.
* All that holds true for `ComatoseAdminController` and the `comatose.admin_includes` and `comatose.admin_helpers` as well.
* `comatose.admin_get_author` and `comatose.admin_get_root_page` both accept a block of code that should return the author and root_page respectively.
You can use any default controller method, as well as methods from included modules
* `comatose.admin_authorization` is using a method from an included module directly, the `:admin_required` method from the `AuthenticatedSystem` module.
The options that accept blocks will also accept symbols representing module methods.
* Have a look at the [config class][] for all the options
Also, there are **unit tests** now. Yay!
You can get an overview of the [coverage][], if you like. Oh, using `rake test:plugins` doesn’t work, to run them you will need to change into the `vendor/plugins/comatose` directory and run `rake`, _after_ you’ve run the Comatose migrations.
From the [CHANGELOG][]:
- Now ONLY supports Rails 1.2 (not even tested in Rails 1.1)
- New configuration system
- DEFER_COMATOSE_LOAD is gone — Using Dispatcher.to_prepare replaces it
- You no longer extend the base classes to add functionality. You configure Comatose to include modules and send it symbols for providing said functionality. e.g. Comatose.config.includes << :authentiation_system; Comatose.config.authorization = :require_login
- The automatic loading of RAILS_ROOT/lib/comatose/*.rb files is NO longer supported.
- In addition to mapping comatose_root in your routes.rb, you’ll want to map.comatose_admin as well
Obviously, if you have any issues with this version, please let me know.
[coverage]:http://mattmccray.com/svn/rails/plugins/comatose/SPECS
[version 0.7.1]:http://mattmccray.com/svn/rails/plugins/tags/comatose_0-7-1/
[dev blog]:http://comatose.rubyforge.org/dev-blog.html
[CHANGELOG]:http://mattmccray.com/svn/rails/plugins/comatose/CHANGELOG
[helpers]:http://api.rubyonrails.com/classes/ActionController/Helpers/ClassMethods.html#M000164
[config class]:http://mattmccray.com/svn/rails/plugins/comatose/lib/comatose/configuration.rb
February 6, 2007 at 9:40 am
I just installed 0.8 and the default home page would not load. The full_path field is set to NULL but the query searches for a page with full_path=”
MySQL doesn’t return anything for that query. I changed the full path with:
update comatose_controller set full_path=” where id=1;
and it started working.
February 9, 2007 at 3:08 pm
Thanks for your great plugins.
When will be support for rails 1.2 in theme plugin available?
February 10, 2007 at 11:14 am
Just installed 0.8 with Rails 1.2.1. Clean rails application.
I followed the new instructions, but browsing to localhost:3000/root gives me no content and localhost:3000/comatose_admin gives me no content.
My development.log has errors that the Comatose::Controller (sometimes), ComatoseAdminController, and ComoatoseController can’t seem to find their helpers.
February 11, 2007 at 6:18 am
Thanks for this great CMS plugin. I have a question that how can I set the layout to use other filename for admin_controller?
February 13, 2007 at 7:59 am
Hi, thanks for a great plugin… I’m just trying to get the new version working and I’m having issues, mainly to do with the new controllers not inheriting from ApplicationController. I’m using Comatose for some pages and Rails to do others, and use ApplicationController to share methods between them. Is it a proplem to make them inherit?\n\n Another problem is that I can’t set extra ‘before_filters’ for the Comatose Controllers. Any chance of an extra configuration option?\n\n Finally… The controller now defaults to using a page with path ‘404′ for not found messages. Is there a way of ensureing that it sends a ‘404 status’ header, as Google requires that non existant pages return a proper 404 before it allows people to use it’s webmaster tools.\n\nCheers\n
February 13, 2007 at 8:01 am
Ooops, there’s a little issue with you’re preview button. When I previewed the post the paragraphs were all there, however they seem to have been replaced with ‘n’s in the actual post.
February 20, 2007 at 10:10 am
Found a small bug? in this version!
Found that filter :handle_authorization is being called more and more times when using comatose.
The reason is that in comaoste.rb, it’s “load ‘controller.rb’” rather than “require ‘controller.rb’”.
I think that’s good for developing. but when using “load”, there will be more and more filters added to filter_chain. And finally this will kill comatose controller. admincontroller has this problem too, since “load ‘admincontroller’”.
Any better solution for this?
February 27, 2007 at 12:55 am
Matt, nice work! Comatose is fantastic. Are you dropping back a bit with its development? I see the dev blog hasn’t been updated? We’re a tad hesitant to update until the dev blog brings us up to date on the new version….
Keep up the great work.
Cheers,
Galen
March 1, 2007 at 10:05 am
I just installed the 0.8 for Rails 1.2.2 and have problems with the migration script. I get the following error;
> rake db:migrate
rake aborted!
Mysql::Error: #42S02Table ‘artdoxa_development.page_versions’ doesn’t exist: SHOW FIELDS FROM page_versions
How do I get this to work? Any suggestions?
Thanks and Regards,
Shafeer
March 1, 2007 at 10:14 am
A note to the actual post. Looking at the stack trace, the error is thrown by acts_as_versioned (at line 4) in the migration script.\n\n
\n acts_as_versioned :if_changed => [:title, :slug, :keywords, :body]\nMarch 14, 2007 at 1:02 pm
how does modules work, now that the conroller hacking is out? Where would I put a module I want included?
March 21, 2007 at 10:46 pm
To Wes (and anyone new who is confused by his post), you want:
mysql> update comatose_pages set full_path=” where id=1;
I spent some time trying to figure out how to update a controller
April 11, 2007 at 3:44 am
Is there any way to extend the get_page_path method without making changes to the plugin? I wanted to append the path with language specific page to support internationalization.
Any ideas would be appreciated!
May 2, 2007 at 6:42 am
Hey Matt, nice work on this plugin! I’m curious when you’ll update the dev blog, I’m a little stuck in the installation of Comatose and the dev blog hasn’t got any information on 0.8 yet…
Keep up the good work, cheers!
Marcel.