Bharat Ruparel wrote:
> Hello Elliott,
> Are you sure that:
> 
> 1.  You have these roles defined in the roles table?  and;
> 2. There is an entry for row_id and user_id in your roles_users table?
> 
> For example,
> 
> If admin user has a user_id of 1 in users table and your roles table
> defines the "admin" role with a role_id = 1 then you must have a row
> in roles_users table corresponding to this combination:
> 
> role_id = 1, user_id = 1
> 
> Check if you have done this.
> Bharat

Sorry for resurrecting an old thread, but this situation describes 
exactly the situation I have set up.  Yet I can't get the user to 
authenticate as an administrator.

I have a single user who I have granted admin rights, in the
admins_users table:

| admin_id | user_id |
+----------+---------+
|        1 |       1 |

Where in the user table the user has ID = 1.  The user is also in the
admins table:

| id | name |
+----+------+
|  1 | test |

However, I am seeing this query deny the user access:

 User Columns (1.3ms)   SHOW FIELDS FROM `users`
  User Load (0.5ms)   SELECT * FROM `users` WHERE (`users`.`id` = 1) 
LIMIT 1
  admins_users Columns (0.8ms)   SHOW FIELDS FROM `admins_users`
  Admin Load (1.2ms)   SELECT * FROM `admins` INNER JOIN
`admins_users` ON `admins`.id = `admins_users`.admin_id WHERE
(`admins_users`.user_id = 1 )
  Admin Columns (0.8ms)   SHOW FIELDS FROM `admins`
Filter chain halted as [:check_roles] rendered_or_redirected.

I always end up with the following text:

'You don't have access here.'

It seems like something is going wrong here:

def check_roles
      return access_denied unless self.class.<%= users_name
%>_authorized_for?(current_<%= users_name %>, params, binding)

      true
    end

However, I can't seem to discover why the user is denied access.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to