# UserEngine - rake bootstrap aborted

**URL:** <https://www.ruby-forum.com/t/userengine-rake-bootstrap-aborted/97024>\
**Category:** Rails\
**Created:** [December 9, 2005, 6:19pm UTC](https://www.ruby-forum.com/t/userengine-rake-bootstrap-aborted/97024 "2005-12-09T18:19:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [December 9, 2005, 6:19pm UTC](https://www.ruby-forum.com/t/userengine-rake-bootstrap-aborted/97024/1 "2005-12-09T18:19:21Z")

</div>

Hi there,  
I’ve just installed login\_engine and user\_engine from the repositories,  
followed the setup procedures as documented in:  
vendor/plugins/user\_engine/README

But I’m getting the following failure:

vince@vaio:~/Projects/Booking$ rake bootstrap  
(in /home/vince/Projects/Booking)  
rake aborted!  
undefined method `edit' for class `UserController’

I’ve commented out the following:

# We need to wrap around the old edit

# alias :old\_edit :edit

# def edit

# @all\_roles = Role.find\_all.select { |r| r.name !=

# UserEngine.config(:guest\_role\_name) }

# old\_edit

# end

(vendor/plugins/user\_engine/app/controllers/user\_controller.rb)

It appears to have worked correctly and created the the default roles.

Is this just depreciated code/bug, or will i run into problems later on?

Cheers,  
-v

–  
keys: [http://codex.net/gpg.asc](http://codex.net/gpg.asc)

You can never plan the future by the past.  
– Edmund Burke

---

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [December 9, 2005, 6:39pm UTC](https://www.ruby-forum.com/t/userengine-rake-bootstrap-aborted/97024/2 "2005-12-09T18:39:44Z")

</div>

Hi Vincent,

edit following file:

$RAILS\_ROOT/vendor/plugins/user\_engine/app/models/permission.rb

In method synchronize\_with\_controllers find lines that say:

# we need to load all the controllers…

controller\_files.each do |file\_name|

and add a sort call in the second one:

# we need to load all the controllers…

controller\_files.sort.each do |file\_name|

Remove comments from the UserController and everything should work fine.

There is a dependency between UserEngine and LoginEngine which is not  
taken  
into account while loading controllers. It is just a quick hack but  
works  
for now.

It would be nice to have some way of specyfying dependencies between  
engines… On the other side it might unnecessary complicate things.  
Something to think about later 😉

Regards,

Bragi

---

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [December 9, 2005, 6:43pm UTC](https://www.ruby-forum.com/t/userengine-rake-bootstrap-aborted/97024/3 "2005-12-09T18:43:50Z")

</div>

Never use alias or alias\_method in classes that potentially can be  
reloaded in  
the development mode. That includes controllers, models, helpers, etc.  
The  
first call to alias works fine, but the second one fails just like in  
your  
case.

Kent.

---

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [December 9, 2005, 7:48pm UTC](https://www.ruby-forum.com/t/userengine-rake-bootstrap-aborted/97024/4 "2005-12-09T19:48:21Z")

</div>

Excellent, that worked fine, cheers.  
but now I’ve encountered another problem, attempting to navigate to the  
/user page fails to prompt with a login screen. The browsers  
(galeon/firefox) are reporting “redirected too many times”. I have  
stopped WEBrick, deleted the sessions, removed the cookies and started  
over, but its still doing it.

#if bragi.ragnarson /\* Dec 09, 06:36 \*/

> Remove comments from the UserController and everything should work  
> On 09/12/05, Vincent AE Scott \<[1]removed\_email\_address@domain.invalid\> wrote:  
> undefined method `edit' for class `UserController’  
> roles.  
> Is this just depreciated code/bug, or will i run into problems  
> later on?  
> Cheers,  
> -v

#endif /\* removed\_email\_address@domain.invalid \*/

–  
keys: [http://codex.net/gpg.asc](http://codex.net/gpg.asc)

Just remember, once you’re over the hill you begin to pick up speed.  
– Arthur Schopenhauer

---

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [December 9, 2005, 8:18pm UTC](https://www.ruby-forum.com/t/userengine-rake-bootstrap-aborted/97024/5 "2005-12-09T20:18:25Z")

</div>

Hi,

This means that UserEngine is right now configured to request login when  
you  
access login page.

My first guess is to cleanup roles, permissions and users tables and  
start  
bootstrap again. If this will not work you will have to manually  
(through  
SQL interface or using rails console) add permission to ‘user/login’ to  
‘Guest’ role.

Regards,  
Bragi

---

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [December 10, 2005, 12:17pm UTC](https://www.ruby-forum.com/t/userengine-rake-bootstrap-aborted/97024/6 "2005-12-10T12:17:36Z")

</div>

#if bragi.ragnarson /\* Dec 09, 08:17 \*/

> Hi,  
> This means that UserEngine is right now configured to request login  
> when you access login page.  
> My first guess is to cleanup roles, permissions and users tables and  
> start bootstrap again. If this will not work you will have to manually  
> (through SQL interface or using rails console) add permission to  
> ‘user/login’ to ‘Guest’ role.  
> Regards,  
> Bragi

yes, spot on again.

The permissions\_roles table was empty, so i had to INSERT a row into it  
as you suggested. For anyone else having the same problem:

SELECT id FROM roles WHERE name=‘Guest’; # x  
SELECT id FROM permissions WHERE controller=‘user’ AND action=‘login’;

# y

INSERT into permissions\_roles (role\_id, permission\_id) VALUES ( x, y );

If i get a chance over the weekend I’ll try and take a looksee as to why  
the bootstrap didn’t complete this task for me.

-v

> ```
> over, but its still doing it.
> > # we need to load all the controllers...
> between
> > repositories,
> > # def edit
> problems
> Rails mailing list
> 
> ```
> 
> 1. [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 2. [http://codex.net/gpg.asc](http://codex.net/gpg.asc)
> 3. [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 4. [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

#endif /\* removed\_email\_address@domain.invalid \*/

–  
keys: [http://codex.net/gpg.asc](http://codex.net/gpg.asc)

Brain: an apparatus with which we think we think.  
– Ambrose Bierce

---

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [December 10, 2005, 3:17pm UTC](https://www.ruby-forum.com/t/userengine-rake-bootstrap-aborted/97024/7 "2005-12-10T15:17:56Z")

</div>

I have found it is an issue with needing to save the role before the  
permissions are added. I created a new rake file for the bootstrap to  
fix  
this, but have not yet submitted it.

Below you will find new code for only the :create\_roles task  
plugins/user\_engine/tasks/user\_engine.rake

* * *

desc ‘Create the default roles’  
task :create\_roles =\> :environment do

# Create the Guest Role

if Role.find\_by\_name(UserEngine.config(:guest\_role\_name)) == nil  
puts “Creating guest role ‘#{UserEngine.config(:guest\_role\_name)}’”  
guest = Role.new  
guest.name = UserEngine.config(:guest\_role\_name)  
guest.description = “Implicit role for all accessors of the site”  
guest.system\_role = true  
guest.omnipotent = false  
guest.save

```
guest.permissions << 

```

Permission.find\_by\_controller\_and\_action(‘user’,  
‘login’)  
guest.permissions \<\<  
Permission.find\_by\_controller\_and\_action(‘user’,  
‘forgot\_password’)  
guest.permissions \<\<  
Permission.find\_by\_controller\_and\_action(‘user’,  
‘signup’)  
end

@all\_action\_permissions = Permission.find\_all

# Create the Admin role

if Role.find\_by\_name(UserEngine.config(:admin\_role\_name)) == nil  
puts “Creating admin role ‘#{UserEngine.config(:admin\_role\_name)}’”  
admin = Role.new  
admin.name = UserEngine.config(:admin\_role\_name)  
admin.description = “The system administrator, with REAL ULTIMATE  
POWER.”  
admin.omnipotent = true  
admin.system\_role = true

```
admin.save

@all_action_permissions.each { |permission|
  if !admin.permissions.include?(permission)
    admin.permissions << permission
  end
}

```

end

# Create the User role, if needed

if Role.find\_by\_name(UserEngine.config(:user\_role\_name)) == nil  
puts “Creating user role ‘#{UserEngine.config(:user\_role\_name)}’”  
user = Role.new  
user.name = UserEngine.config(:user\_role\_name)  
user.description = “The default role for all logged-in users”  
user.system\_role = true  
user.omnipotent = false  
user.save

```
# all users automatically get the Guest permissions implicitly
user.permissions << Permission.find_by_controller_and_action('user',

```

## ‘logout’) user.permissions \<\< Permission.find\_by\_controller\_and\_action(‘user’, ‘home’) user.permissions \<\< Permission.find\_by\_controller\_and\_action(‘user’, ‘change\_password’) user.permissions \<\< Permission.find\_by\_controller\_and\_action(‘user’, ‘edit’) end End

-Nb

```auto
 Nathaniel S. H. Brown http://nshb.net

```

---

<div class="post-metadata">

**Author:** ![rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@rails](https://www.ruby-forum.com/u/rails)\
**Post date:** [December 10, 2005, 9:10pm UTC](https://www.ruby-forum.com/t/userengine-rake-bootstrap-aborted/97024/8 "2005-12-10T21:10:12Z")

</div>

Hi all

Nathaniel has been busy finding these bugs, and filing requests on the  
Engines Trac site, which I’d encourage you all to peruse. I should  
have a bug fix version out late next week - alas, Real Life is  
forcing me to focus my energies elsewhere until then…

- james
