Showing posts with label comatose. Show all posts
Showing posts with label comatose. Show all posts

Thursday, April 10, 2008

Design Free Administration Back Office For Rails Application

There are some common concerns to build a back office for a rails project. Not like the front pages, which are usually designed by professional web designers, back office pages often need to be scratched by programmers. It often takes me a lot of time to do the layout, HTML structures, header and footer, div content boxes, list table styles and form field styles. Though I am familiar with CSS, I still troubled a lot with the overall look and feel because of my lack of the web design gene. So I am writing here to conclude a way to be design fee....

1. Install my plugin uni_admin for admin layout, table styles:

http://code.google.com/p/ruby-on-rails-plugin-uni-admin/

2. Install uni-form and my uni-form-patch for form styles

http://code.google.com/p/rails-uni-form-patch/

3. Install plugin restful authentication for basic authentication

http://xiaoboonrails.blogspot.com/2008/02/install-and-config-rails-plugin.html

4. If you have installed comatose, it is easy to integrate comatose_admin with uni_admin layout
rake comatose:admin:customize
update related content of layouts/uni_admin_layout.html.erb to layouts/comatose_admin.rhtml

Thursday, February 14, 2008

Install and config rails plugin restful_authentication

Ruby on rails plugin Restful_authentication is a basic plugin useful for most of rails applications. It is very easy to intall and config it:
script/plugin source http://svn.techno-weenie.net/projects/plugins
script/plugin install restful_authentication
script/generate authenticated user sessions
rake db:migrate

Check the code in your routes.rb which is automatically added by the generation
map.resources :users
map.resource :session

Add more route mapping if your want
map.signup '/signup', :controller => 'users', :action => 'new'
map.login '/login', :controller => 'sessions', :action => 'new'
map.logout '/logout', :controller => 'sessions', :action => 'destroy'

Visit http://localhost:3000/users/new or http://localhost:3000/signup

Then to make it work with Comatose, add comatose config to evironment.rb of your app:
Comatose.configure do |config|
# Includes AuthenticationSystem in the ComatoseAdminController
config.admin_includes << :authenticated_system

# Calls :login_required as a before_filter
config.admin_authorization = :login_required
end

Thursday, February 7, 2008

Some problems of the installation of Rails Comatose Plugin

Comatose is a very handy content management ruby on rails plugin. Here I am listing some problems that I encountered when I get Comatose running correctly. Most of them can be easily fixed by googling. It is just a quick summary just in case you get the same kinds of problems or errors as I did.

To install it:
script/plugin install http://comatose-plugin.googlecode.com/svn/trunk/comatose
script/generate comatose_migration
rake db:migrate
# add to your routes.rb:
map.comatose_admin
map.comatose_root 'pages'
script/server
# visit content admin http://localhost:3000/comatose_admin
# after add a page of name My Page
# visit it at http://localhost:3000/pages/my-page

1. Do rake db migration, get a Mysql::Error: BLOB/TEXT column 'full_path' can't have a default value. To fix it, remove ":default => ''" from the definition of column 'full_path', in the migration file db/migrate/xxx_add_comatose_support.rb

2. To start your rails app, get an error `method_missing': undefined method `comatose_admin' for #. I got this routing error after I use Active Merchant plugin, can not figure out why. Add this to environment.rb to make Comatose plugin be loaded firstly:
config.plugins = [ :comatose, :all ]

3. Install necessary plugins
./script/plugin install acts_as_tree
./script/plugin install acts_as_list

4. To customize comatose admin view
rake comatose:admin:customize

This task will copy all of admin view rthml files to app/view/comatose_admin directory of your rails app. There is a new layout file comatose_admin.rhtml. Modify this layout file to customize your admin view.