Thank you so much for your email. I have updated the project a fair bit recently and its been some time since I tested it out creating a project from scratch. I will try that ASAP and release some fixes for any bugs.
Thanks for the clear bug report!
For the devise_for to work with User, the User model must be "decorated" with a devise statement stating which authentication strategies to use as far as I know.
I will try the full config generator tomorrow and make sure it is working.
> rails g cream:full_config --roles guest user editor admin
Active Record and role_string should be the defaults ;)
Kristian
I just fixed the bugs.
I got the same error running with your sample arguments and now after the fix it runs without problems.
The devise:configure generator was missing an orm argument in the #routes_configure! method like you said and there was also a minor error in one of the gems which cream depend on.
Please let me know if it works for you now :)
Cheers!
Kris
On Jan 1, 2011, at 7:45 PM, Will Merrell wrote:
Well, not quite.
There still seems to be two problems.
First, the devise integration still raises an error, after which
everything is suspect. See the listing below to see what happened there.
Second, as an experiment I did the devise install and user setup
manually and included a scaffold table so the app would have something
to do. Once I had this working and tested, then I did the
cream:full_config. It breezed though the devise and cancan stuff, and
then started showing problems in the rolls part. It seems it went to
modify the user model and did odd things to it that broke it. The error
message below
[WARNING] You provided devise_for :users but there is no model User
defined in your application
first appears part way though this run as you can see below.
I think that the code that inserts the roles stuff is doing it wrong and
it may be messing up something else. I tryed a little editing of the
user file after the run, but could not find a way that worked.
Please take a look and give me some guidance.
-- Will
Here is the resulting user.rb file:
================= user.rb ================
use_roles_strategy :role_string
class User
valid_roles_are Cream::Role.available < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
end
================ end user.rb ================
Below is the output from running this:
================ Output from cream:full_config: ===============
will@silver:~/rails/cream_app$ rails g cream:full_config --roles one two
three
[Rails3::Assist::Logging]
rails g cream:app --orm active_record
run rails g cream:app --orm active_record from "."
[Rails3::Assist::Logging]
insert_flash_displayer: alert
insert_flash_displayer: notice
rails g devise:config --orm active_record
run rails g devise:config --orm active_record from "."
Configuring devise gems for active_record
[Rails3::Assist::Logging]
gem: devise already in Gemfile
Orm active_record is not currently supported by Cream. You are most
welcome to provide a Cream adapter for that ORM ;)
run bundle install from "."
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.23)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.13)
Using actionmailer (3.0.3)
Using arel (2.0.6)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bcrypt-ruby (2.1.3)
Using bundler (1.0.7)
Using cancan (1.4.1)
Using log4r (1.1.9)
Using require_all (1.2.0)
Using mocha (0.9.10)
Using sugar-high (0.3.1)
Using logging_assist (0.1.6)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
Using migration_assist (0.1.8)
Using rails3_assist (0.3.6)
Using rspec-core (2.3.1)
Using diff-lcs (1.1.2)
Using rspec-expectations (2.3.0)
Using rspec-mocks (2.3.0)
Using rspec (2.3.0)
Using rails3_artifactor (0.3.2)
Using cancan-permits (0.3.7)
Using r3_plugin_toolbox (0.4.0)
Using cancan-rest-links (0.2.1)
Using warden (1.0.3)
Using devise (1.1.5)
Using devise-links (0.2.1)
Using cream (0.8.4)
Using meta_where (0.9.9.2)
Using roles_generic (0.3.5)
Using roles_active_record (0.4.3)
Using sqlite3-ruby (1.3.2)
Your bundle is complete! Use `bundle show [gemname]` to see where a
bundled gem is installed.
initializers/devise.rb was found so devise:install will not be run
Configuring: devise mailer
Configuring: devise authentication filter
rails g devise:users --orm active_record --no-gems
run rails g devise:users --orm active_record --no-gems from "."
[Rails3::Assist::Logging]
Configure Devise Users
rails g cancan:config --orm active_record --no-gems
run rails g cancan:config --orm active_record --no-gems from "."
[Rails3::Assist::Logging]
Insert cancan rescue statement into application controller
rails g roles:config --orm active_record --roles one two three guest
admin --strategy role_string
run rails g roles:config --orm active_record --roles one two
three guest admin --strategy role_string from "."
run bundle install from "."
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.23)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.13)
Using actionmailer (3.0.3)
Using arel (2.0.6)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bcrypt-ruby (2.1.3)
Using bundler (1.0.7)
Using cancan (1.4.1)
Using log4r (1.1.9)
Using require_all (1.2.0)
Using mocha (0.9.10)
Using sugar-high (0.3.1)
Using logging_assist (0.1.6)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
Using migration_assist (0.1.8)
Using rails3_assist (0.3.6)
Using rspec-core (2.3.1)
Using diff-lcs (1.1.2)
Using rspec-expectations (2.3.0)
Using rspec-mocks (2.3.0)
Using rspec (2.3.0)
Using rails3_artifactor (0.3.2)
Using cancan-permits (0.3.7)
Using r3_plugin_toolbox (0.4.0)
Using cancan-rest-links (0.2.1)
Using warden (1.0.3)
Using devise (1.1.5)
Using devise-links (0.2.1)
Using cream (0.8.4)
Using meta_where (0.9.9.2)
Using roles_generic (0.3.5)
Using roles_active_record (0.4.3)
Using sqlite3-ruby (1.3.2)
Your bundle is complete! Use `bundle show [gemname]` to see where a
bundled gem is installed.
[Rails3::Assist::Logging]
rails g active_record:roles User --strategy role_string --roles one two
three guest admin --default-roles
run rails g active_record:roles User --strategy role_string
--roles one two three guest admin --default-roles from "."
[Rails3::Assist::Logging]
apply_role_strategy for : role_string in model User
insert app/models/user.rb
rails g permits:config --orm active_record --roles one two three guest
admin --no-gems
run rails g permits:config --orm active_record --roles one two
three guest admin --no-gems from "."
[WARNING] You provided devise_for :users but there is no model User
defined in your application
[Rails3::Assist::Logging]
Configure Permits
rails g cancan:permits --roles one two three guest admin --orm active_record
run rails g cancan:permits --roles one two three guest admin
--orm active_record from "."
[WARNING] You provided devise_for :users but there is no model User
defined in your application
create app/permits/guest_permit.rb
create app/permits/admin_permit.rb
create app/permits/any_permit.rb
create app/permits/system_permit.rb
rails g cancan:licenses
run rails g cancan:licenses from "."
[WARNING] You provided devise_for :users but there is no model User
defined in your application
create app/licenses/user_admin_license.rb
create app/licenses/blogging_license.rb
=================== End of output from cream:full_config:
===================
====== Output for devise failure: ================
will@silver:~/rails/cream_app2$ rails g cream:full_config --roles one
two three
[Rails3::Assist::Logging]
rails g cream:app --orm active_record
run rails g cream:app --orm active_record from "."
[Rails3::Assist::Logging]
insert_flash_displayer: alert
insert_flash_displayer: notice
rails g devise:config --orm active_record
run rails g devise:config --orm active_record from "."
Configuring devise gems for active_record
[Rails3::Assist::Logging]
Adding gem: devise
gemfile devise
Orm active_record is not currently supported by Cream. You are most
welcome to provide a Cream adapter for that ORM ;)
run bundle install from "."
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.23)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.13)
Using actionmailer (3.0.3)
Using arel (2.0.6)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bcrypt-ruby (2.1.3)
Using bundler (1.0.7)
Using cancan (1.4.1)
Using log4r (1.1.9)
Using require_all (1.2.0)
Using mocha (0.9.10)
Using sugar-high (0.3.1)
Using logging_assist (0.1.6)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
Using migration_assist (0.1.8)
Using rails3_assist (0.3.6)
Using rspec-core (2.3.1)
Using diff-lcs (1.1.2)
Using rspec-expectations (2.3.0)
Using rspec-mocks (2.3.0)
Using rspec (2.3.0)
Using rails3_artifactor (0.3.2)
Using cancan-permits (0.3.7)
Using r3_plugin_toolbox (0.4.0)
Using cancan-rest-links (0.2.1)
Using warden (1.0.3)
Using devise (1.1.5)
Using devise-links (0.2.1)
Using cream (0.8.4)
Using sqlite3-ruby (1.3.2)
Your bundle is complete! Use `bundle show [gemname]` to see where a
bundled gem is installed.
initializers/devise.rb was NOT found so devise:install will now be run
rails g devise:install
run rails g devise:install from "."
create config/initializers/devise.rb
create config/locales/devise.en.yml
===============================================================================
Some setup you must do manually if you haven't yet:
1. Setup default url options for your specific environment. Here is an
example of development environment:
config.action_mailer.default_url_options = { :host =>
'localhost:3000' }
This is a required Rails configuration. In production it must be the
actual host of your application
2. Ensure you have defined root_url to *something* in your
config/routes.rb.
For example:
root :to => "home#index"
3. Ensure you have flash messages in
app/views/layouts/application.html.erb.
For example:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
===============================================================================
Configuring: devise mailer
Configuring: devise authentication filter
rails g devise:users --orm active_record --no-gems
run rails g devise:users --orm active_record --no-gems from "."
[WARNING] You provided devise_for :users but there is no model User
defined in your application
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.3.1/lib/rspec/core/backward_compatibility.rb:20:in
`const_missing': uninitialized constant User (NameError)
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/inflector/methods.rb:124:in
`block in constantize'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/inflector/methods.rb:123:in
`each'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/inflector/methods.rb:123:in
`constantize'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/devise-1.1.5/lib/devise/mapping.rb:69:in
`to'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/devise-1.1.5/lib/devise/mapping.rb:64:in
`modules'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/devise-1.1.5/lib/devise/mapping.rb:73:in
`strategies'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/devise-1.1.5/lib/devise.rb:281:in
`block in configure_warden!'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/devise-1.1.5/lib/devise.rb:280:in
`each_value'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/devise-1.1.5/lib/devise.rb:280:in
`configure_warden!'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/devise-1.1.5/lib/devise/rails/routes.rb:7:in
`finalize_with_devise!'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:128:in
`block in reload_routes!'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in
`instance_eval'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in
`execute_hook'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:26:in
`on_load'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:128:in
`reload_routes!'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:120:in
`block in routes_reloader'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in
`call'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in
`execute_if_updated'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application/finisher.rb:51:in
`block (2 levels) in <module:Finisher>'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application/finisher.rb:52:in
`call'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application/finisher.rb:52:in
`block in <module:Finisher>'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/initializable.rb:25:in
`instance_exec'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/initializable.rb:25:in
`run'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/initializable.rb:50:in
`block in run_initializers'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/initializable.rb:49:in
`each'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/initializable.rb:49:in
`run_initializers'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:134:in
`initialize!'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:77:in
`method_missing'
from /home/will/rails/cream_app2/config/environment.rb:5:in `<top
(required)>'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/application.rb:103:in
`require_environment!'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands.rb:16:in
`<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
rails g cancan:config --orm active_record --no-gems
run rails g cancan:config --orm active_record --no-gems from "."
^C/home/will/.rvm/gems/ruby-1.9.2-p136/gems/arel-2.0.6/lib/arel/nodes.rb:12:in
`require': Interrupt
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/arel-2.0.6/lib/arel/nodes.rb:12:in
`<top (required)>'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/arel-2.0.6/lib/arel.rb:22:in
`require'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/arel-2.0.6/lib/arel.rb:22:in
`<top (required)>'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record.rb:34:in
`require'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record.rb:34:in
`<top (required)>'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/railtie.rb:1:in
`require'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/railtie.rb:1:in
`<top (required)>'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/all.rb:11:in
`require'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/all.rb:11:in
`block in <top (required)>'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/all.rb:5:in
`each'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/all.rb:5:in
`<top (required)>'
from /home/will/rails/cream_app2/config/application.rb:3:in `require'
from /home/will/rails/cream_app2/config/application.rb:3:in `<top
(required)>'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands.rb:15:in
`require'
from
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands.rb:15:in
`<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
================== End of output for devise failure: ===================
Was mssing class macro call
use_orm :active_record
in order to insert code correctly into the User model. Thats why devise complained, coz the code was inserted after User but before < ActiveRecord::Base
Sorry, something with the devise integration is still not right. Below I
include the output from the run. It failed on the creation of the devise
user file. It did insert the devise_for into the routes file, but it did
not create the migration file and it did not create the model file.
-- Will
==================================
will@silver:~/rails/cream_app$ rails g cream:full_config --strategy
role_string --roles guest user editor admin
Using rspec-core (2.4.0)
Using diff-lcs (1.1.2)
Using rspec-expectations (2.4.0)
Using rspec-mocks (2.4.0)
Using rspec (2.4.0)
Using rails3_artifactor (0.3.2)
Using cancan-permits (0.3.7)
Using r3_plugin_toolbox (0.4.0)
Using cancan-rest-links (0.2.1)
Using warden (1.0.3)
Using devise (1.1.5)
Using devise-links (0.2.1)
Using cream (0.8.5)
===============================================================================
root :to => "home#index"
/home/will/.rvm/gems/ruby-1.9.2-p136/gems/rspec-core-2.4.0/lib/rspec/core/backward_compatibility.rb:20:in
from /home/will/rails/cream_app/config/environment.rb:5:in `<top