# Rake bootstrap --trace: undefined method \`roles' for #\<User:

**URL:** <https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843>\
**Category:** Engines\
**Created:** [February 15, 2006, 6:05am UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843 "2006-02-15T06:05:30Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 15, 2006, 6:05am UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/1 "2006-02-15T06:05:30Z")

</div>

rake bootstrap --trace

dies with:

\*\* Invoke bootstrap (first\_time)  
\*\* Invoke sync\_permissions (first\_time)  
\*\* Invoke environment (first\_time)  
\*\* Execute environment  
\*\* Execute sync\_permissions  
\*\* Invoke create\_roles (first\_time)  
\*\* Invoke environment  
\*\* Execute create\_roles  
\*\* Invoke create\_admin\_user (first\_time)  
\*\* Invoke environment  
\*\* Execute create\_admin\_user  
rake aborted!  
undefined method `roles' for #<User:0xb7633288> /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1501:in`method\_missing’  
./vendor/plugins/user\_engine/tasks/user\_engine.rake:30  
/usr/lib/ruby/1.8/rake.rb:232:in `execute' /usr/lib/ruby/1.8/rake.rb:232:in`execute’  
/usr/lib/ruby/1.8/rake.rb:202:in `invoke' /usr/lib/ruby/1.8/thread.rb:135:in`synchronize’  
/usr/lib/ruby/1.8/rake.rb:195:in `invoke' /usr/lib/ruby/1.8/rake.rb:209:in`invoke\_prerequisites’  
/usr/lib/ruby/1.8/rake.rb:844:in `each' /usr/lib/ruby/1.8/rake.rb:208:in`invoke\_prerequisites’  
/usr/lib/ruby/1.8/rake.rb:201:in `invoke' /usr/lib/ruby/1.8/thread.rb:135:in`synchronize’  
/usr/lib/ruby/1.8/rake.rb:195:in `invoke' /usr/lib/ruby/1.8/rake.rb:1719:in`run’  
/usr/lib/ruby/1.8/rake.rb:1719:in `run’  
/usr/bin/rake:4

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 1:47am UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/2 "2006-02-16T01:47:24Z")

</div>

In addition I’m getting this error in my main controller:

NoMethodError in Home#index

undefined method `guest\_user\_authorized?’ for User:Class

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 4:46pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/3 "2006-02-16T16:46:37Z")

</div>

Can you confirm that you’ve run ‘rake engine\_migrate  
ENGINE=user\_engine’, or just ‘rake engine\_migrate’ after installing  
the user engine? In other words, do you definitely have the user  
engine database tables?

- james

On 2/15/06, Greg D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \*\* Invoke create\_roles (first\_time)  
> /usr/lib/ruby/1.8/rake.rb:232:in `execute' /usr/lib/ruby/1.8/rake.rb:1719:in `run’  
> /usr/lib/ruby/1.8/rake.rb:1719:in `run’  
> /usr/bin/rake:4
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> engine-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 4:46pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/4 "2006-02-16T16:46:37Z")

</div>

Also, which verson of Rails are you using?

On 2/16/06, James A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > \*\* Invoke create\_admin\_user (first\_time)  
> > /usr/lib/ruby/1.8/thread.rb:135:in `synchronize’
> 
> - J \*  
> ~

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 4:49pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/5 "2006-02-16T16:49:39Z")

</div>

It sounds very much like you haven’t properly installed the user  
engine. Did you follow the user engine README file step by step?

It’s also possible that your version of Rails (1.0? InstantRails?  
Locomotive?) isn’t playing nice with the engines plugin. Be sure to  
update to the latest release (or the SVN trunk if you’re using edge  
rails, there are a few more hoops to jump through, check this list’s  
archives).

- james

On 2/16/06, Greg D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> engine-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 4:50pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/6 "2006-02-16T16:50:01Z")

</div>

James A. wrote:

> Can you confirm that you’ve run ‘rake engine\_migrate  
> ENGINE=user\_engine’, or just ‘rake engine\_migrate’ after installing  
> the user engine? In other words, do you definitely have the user  
> engine database tables?

I have run ‘rake engine\_migrate’ successfully. I see several new tables  
were created in my database.

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 4:51pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/7 "2006-02-16T16:51:09Z")

</div>

James A. wrote:

> Also, which verson of Rails are you using?

Rails 1.0 and I also tried for a brief period with Edge Rails.

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 4:55pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/8 "2006-02-16T16:55:56Z")

</div>

James A. wrote:

> It sounds very much like you haven’t properly installed the user  
> engine. Did you follow the user engine README file step by step?

I did a complete install twice, engines, login\_engine, user\_engine, same  
errors both times. Seems like something is loading out of order.

> It’s also possible that your version of Rails (1.0? InstantRails?  
> Locomotive?) isn’t playing nice with the engines plugin.

No idea, since I’ve never seen this work before I have no idea what is  
supposed to be playing with what.

> Be sure to  
> update to the latest release (or the SVN trunk if you’re using edge  
> rails, there are a few more hoops to jump through, check this list’s  
> archives).

I have tried with Rails 1.0 and Edge Rails. Searching for the error  
messages returned no results, so I posted.

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 10:29pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/9 "2006-02-16T22:29:56Z")

</div>

Hi all, I am having the same problem that Greg originally described  
(undefined method: ‘foo’ during the running of the bootstrap), in  
addition to getting

NoMethodError: undefined method ‘guest\_user\_authorized?’ for User::Class

if I brute-force my way past the bootstrap errors by setting the role  
 ↔ permission link manually in the DB. I concur with him that it looks  
like the overrides for the User Class aren’t being loaded, but I don’t  
know why. I’ve tried all of the possible ways to specify engine loading  
in environment.rb, and none of them make a difference. I get the same  
NoMethodError when I try to get something out of ‘User.roles’ in the  
console. I have had a working Login Engine installation in the app for  
a week or two, so I’m pretty sure that part is solid. All of the  
necessary tables also appear to be in place and populated.

I hope something in my rambling helps jog your memory or push you in the  
direction of whatever might by amiss here.

Jim

James A. wrote:

> In a console, can you get and sensible output from
> 
> User.roles
> 
> or
> 
> UserEngine::AuthorizedUser
> 
> ?
> 
> I’m just checking to see if the user engine has been loaded or not.  
> Oh, also check that you’ve got Engines.start :login, :user in your  
> environment.rb file…
> 
> - james
> 
> On 2/16/06, Greg D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > removed\_email\_address@domain.invalid  
> > [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)
> 
> –
> 
> - J \*  
> ~

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 4:58pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/10 "2006-02-16T16:58:45Z")

</div>

In a console, can you get and sensible output from

User.roles

or

UserEngine::AuthorizedUser

?

I’m just checking to see if the user engine has been loaded or not.  
Oh, also check that you’ve got Engines.start :login, :user in your  
environment.rb file…

- james

On 2/16/06, Greg D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 11:28pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/11 "2006-02-16T23:28:40Z")

</div>

Jim K. wrote:

> Hi all, I am having the same problem that Greg originally described  
> (undefined method: ‘foo’ during the running of the bootstrap), in  
> addition to getting  
> And of course, now I’ll reply to myself with all of the info I should  
> have included the first time:

I’m running Rails 1.0 and what appears to be the latest rev of Login and  
User engines  
I’ve tried it on Windows and OS X with the same results both places  
in the console (in response to your second query):

> > User.roles  
> > NoMethodError: undefined method `roles' for User:Class from /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:991:in`method\_missing’  
> > from (irb):3
> 
> > UserEngine::AuthorizedUser  
> > =\> UserEngine::AuthorizedUser
> 
> >

So it knows a little something about the user engine, but it doesn’t  
seem to get everything loaded right. I did notice one oddity in the  
engine docs, but I’m still a bit too green to know if it’s relevant.  
The Login Engine docs mention adding “require ‘login\_engine’” to the top  
of app/controllers/application.rb. However, the user engine docs don’t  
show this. I think I tried several different permutations without  
success, but I could have been flailing at that point.

Jim

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 16, 2006, 11:53pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/12 "2006-02-16T23:53:19Z")

</div>

On 2/16/06, Jim K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Hi all, I am having the same problem that Greg originally described

Trying this on a second Debian box I can complete the login\_engin  
install but then get errors with the user\_engine install:

> rake engine\_migrate  
> (in /home/gcdonald/rails/engine\_test)  
> Migrating engine ‘login\_engine’  
> SQL (0.000000) ERROR: relation “schema\_info” already exists  
> : CREATE TABLE schema\_info (version integer)  
> SQL (0.000000) ERROR: relation “engine\_schema\_info” already exists  
> : CREATE TABLE engine\_schema\_info (engine\_name character varying(255),  
> version integer)  
> SQL (0.000000) ERROR: relation “schema\_info” already exists  
> : CREATE TABLE schema\_info (version integer)  
> SQL (0.000000) ERROR: relation “engine\_schema\_info” already exists  
> : CREATE TABLE engine\_schema\_info (engine\_name character varying(255),  
> version integer)  
> SQL (0.002690) SELECT version FROM engine\_schema\_info WHERE  
> engine\_name = ‘login\_engine’

I also tried:

> rake engine\_migrate ENGINE=user  
> (in /home/gcdonald/rails/engine\_test)  
> Couldn’t find an engine called ‘user’

which is very odd since I didn’t get any errors when I did:

> svn co [http://opensvn.csie.org/rails\_engines/plugins/user\_engine](http://opensvn.csie.org/rails_engines/plugins/user_engine) vendor/plugins/user\_engine

and I can confirm there is a user\_engine installed in vendor/plugins:

> ls -lah vendor/plugins/user\_engine/  
> total 20K  
> drwxr-xr-x 9 gcdonald gcdonald 272 2006-02-16 16:34 .  
> drwxr-xr-x 5 gcdonald gcdonald 136 2006-02-16 16:34 …  
> drwxr-xr-x 7 gcdonald gcdonald 176 2006-02-16 16:34 app  
> drwxr-xr-x 4 gcdonald gcdonald 128 2006-02-16 16:34 db  
> -rw-r–r-- 1 gcdonald gcdonald 1.4K 2006-02-16 16:34 init\_engine.rb  
> drwxr-xr-x 4 gcdonald gcdonald 136 2006-02-16 16:34 lib  
> drwxr-xr-x 5 gcdonald gcdonald 136 2006-02-16 16:34 public  
> -rw-r–r-- 1 gcdonald gcdonald 13K 2006-02-16 16:34 README  
> drwxr-xr-x 7 gcdonald gcdonald 328 2006-02-16 16:34 .svn  
> drwxr-xr-x 3 gcdonald gcdonald 104 2006-02-16 16:34 tasks  
> drwxr-xr-x 6 gcdonald gcdonald 184 2006-02-16 16:34 test

I also tried removing all the tables that were created during the  
login\_engine install, but it didn’t help. I got the same errors as  
with running rake engine\_migrate the first time for the login\_engine.

–  
Greg D.  
Zend Certified Engineer  
MySQL Core Certification  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 20, 2006, 6:59pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/13 "2006-02-20T18:59:23Z")

</div>

Greg D. wrote:

> James A. wrote:
> 
> > also check that you’ve got Engines.start :login, :user in your  
> > environment.rb file…  
> > That wasn’t it for me, but I did find the solution. I had created an  
> > app/models/user.rb file some time back to hold some associations (I must  
> > have done it right when I installed the login engine), and then promptly  
> > forgotten about it. Removing that file caused the NoMethodErrors to  
> > disappear. It’s always the last thing you check…

Jim

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 17, 2006, 4:44am UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/14 "2006-02-17T04:44:41Z")

</div>

James A. wrote:

> also check that you’ve got Engines.start :login, :user in your  
> environment.rb file…

I just had Engines.start, so I tried your suggestion and it seems to  
help. I’m no longer getting the missing method error.

At this point I started seeing some database issues. This error was  
being logged on most every request:

Role Load (0.000000) RuntimeError: ERROR C42P01 Mrelation  
“users\_roles” does not exist Fnamespace.c L200 RRangeVarGetRelid:  
SELECT \* FROM roles LEFT JOIN users\_roles ON roles.id =  
users\_roles.role\_id WHERE (users\_roles.user\_id = 1 )

I didn’t have a user\_roles table, but I had a \_roles table. I tried  
renaming it to user\_roles but it didn’t seem to help even after  
restarting the server. So I dropped all the tables and ran rake  
engine\_migrate again, then rake bootstrap again. This time I had a  
user\_roles table, but when I try to access a page it just sits there,  
never to respond.

I’m not sure what it’s doing, but this is the last thing logged:

Role Count (0.003174) SELECT COUNT(\*) FROM roles  
SQL (0.006606) SELECT a.attname, format\_type(a.atttypid,  
a.atttypmod), d.adsrc, a.attnotnull  
FROM pg\_attribute a LEFT JOIN pg\_attrdef d  
ON a.attrelid = d.adrelid AND a.attnum = d.adnum  
WHERE a.attrelid = ‘roles’::regclass  
AND a.attnum \> 0 AND NOT a.attisdropped  
ORDER BY a.attnum

Role Load (0.002843) SELECT \* FROM roles WHERE (roles.“omnipotent” =  
‘t’ )

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [February 23, 2006, 8:35pm UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/15 "2006-02-23T20:35:36Z")

</div>

Jim K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Greg D. wrote:
> 
> > James A. wrote:
> > 
> > > also check that you’ve got Engines.start :login, :user in your  
> > > environment.rb file…  
> > > That wasn’t it for me, but I did find the solution. I had created an  
> > > app/models/user.rb file some time back to hold some associations (I must  
> > > have done it right when I installed the login engine), and then promptly  
> > > forgotten about it. Removing that file caused the NoMethodErrors to  
> > > disappear. It’s always the last thing you check…

Yeah, I was also facing the same problem. Luckily I found your post and  
removing the user.rb file solved the problem.

–  
Surendra S.  
[http://ssinghi.kreeti.com](http://ssinghi.kreeti.com), [http://www.kreeti.com](http://www.kreeti.com)  
Read the latest news at: [http://news.kreeti.com](http://news.kreeti.com)  
,----  
| “O thou my friend! The prosperity of Crime is like unto the lightning,  
| whose traitorous brilliancies embellish the atmosphere but for an  
| instant, in order to hurl into death’s very depths the luckless one  
| they have dazzled.” – Marquis de Sade  
`----

---

<div class="post-metadata">

**Author:** ![destiney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@destiney](https://www.ruby-forum.com/u/destiney)\
**Post date:** [July 10, 2006, 11:50am UTC](https://www.ruby-forum.com/t/rake-bootstrap-trace-undefined-method-roles-for-user/53843/16 "2006-07-10T11:50:26Z")

</div>

I had to patch the lib\login\_engine.rb and add in the users table. My  
problem was that when doing a migration (rake engine\_migrate) I was only  
getting \_roles table created:

– create\_table("\_roles", {:id=\>false, :force=\>true})

Here’s the patched code - add config: user\_table … (x2)

module UserEngine

#–

# These are the default constants, used if nothing else is specified

#++

# The names of the new Role and Permission tables

if ActiveRecord::Base.pluralize\_table\_names  
config :user\_table, “users”  
config :role\_table, “roles”  
config :permission\_table, “permissions”  
else  
config :user\_table, “user”  
config :role\_table, “role”  
config :permission\_table, “permission”  
end

# Join tables for users \<-\> roles, and roles \<-\> permissions

config :user\_role\_table,  
“#{LoginEngine.config(:user\_table)}_#{config(:role\_table)}"  
config :permission\_role\_table,  
"#{config(:permission\_table)}_#{config(:role\_table)}”

Note: this may have already been patched.
