Perhaps the most powerful part of Cream is the set of generators that work to configure your application for your requirements. h2. Full application configuration The _full_config_ generator is the main generator and attempts to configure an application with Devise, CanCan, Roles and Permits for a given ORM. As of 2011, it now also supports options to set which class names to use for the main model classes generated, including the abstract User, Role and for relational databases the model for the join table between User and Role (default: UserRole). The generator will only run if you pass it a valid strategy and orm combination. 1. Create Cream initializer - which sets up the roles available to Cream (for use in Roles configuration) 2. Optionally generate default locale files for Cream labels (please provide other translations) 3. Run sub generators 4. Optionally run migrations (currently only for Active Record) h3. Sub generators The _full_config_ generator executes the following generators in succession: 1. Cream application configuration 2. Devise configuration 3. CanCan configuration 4. Roles configuration 5. Permits configuration The order is very important! Note: the Devise configuration is split into 'general configuration' followed by a special _devise users__ generator which sets up User models with devise strategies. h2. Cream application configuration 1. Remove AR code from application if non-AR ORM is used 2. Add Welcome controller and view and setup root route if no such exists 3. Add flash message logic to application layout file (as required by devise) In case an ORM is specified other than Active Record (A.R) the generator will attempt to strip A.R code from the application by replacing A.R specific code from the _application.rb_ file. For the application to demonstrate that it works in the end, it is ensured that root route is defined and linked to a Welcome controller action with page. This Welcome controller will be set up with a :before filter to redirect to the login page if the user is not logged in. h2. Devise configuration Consists of: * Devise basic configuration * Devise User configuration h3. Devise basic configuration 1. Run _Devise installer_ (if it hasn't been run before - i.e no _devise.rb_ initializer present) 2. Configure Devise for ORM chosen (installing relevant ORM adapter for Devise) 3. Insert default mailer configuration in _application.rb_ (localhost:3000) - change this for production! 4. Insert a before filter in the Application controller to always require authenticated user (customize this later) As part of this configuration, relevant gem files will be added to the _Gemfile_ and
$ bundle installwill be run to install them and make them available to the app :) h3. Devise users configuration 1. Create devise base User model (note: name of model can be customized) if the user model doesn't already exist 2. Optionally insert default devise strategy in the User model (if not exist) 3. Optionally create an Admin user. The Admin user will always inherit from the base User (using Single Table Inheritance strategy if using Active Record) 4. Create similar models for each role as for Admin user 5. Create special devise routes for each User role with code and notes to aid in further customization if needed With regard to item 3 (creating Admin model), I'm not sure if it makes sense to treat the Admin user as something special or just let it be like any other role? Suggestions and comments welcome! h2. Roles configuration 1. Rune the _Roles generator_ for the ORM selected 2. Replace the valid_roles_are statement in the base User class as generated by the Roles generator with a reference to the roles available defined in Cream initializer (see Cream app generator) h2. Permits configuration 1. Run _CanCan permits_ generator to generate permits for each role for the ORM selected 2. Generate default licenses