Displaying 5 results from an estimated 5 matches for "rights_roles".
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
...MODEL CLASSES:
class User < ActiveRecord::Base
has_and_belongs_to_many :roles
end
class Role < ActiveRecord::Base
has_and_belongs_to_many :users
has_and_belongs_to_many :rights
end
class Right < ActiveRecord::Base
has_and_belongs_to_many :roles
end
TABLES:
users
rights
roles
rights_roles (habtm join table)
roles_users (habtm join table)
All fairly standard stuff.
As my application has evolved I wish to add roles to other things as
well such as groups of users. What I don''t want is to have to create
another join table roles_groups.
I think this can be re-factored usi...
2006 Apr 07
0
HABTM query return all results
...associated with the currently selected
role (passed in through @params[:id]).
Schema:
create_table "rights", :force => true do |t|
t.column "name", :string
t.column "controller", :string
t.column "action", :string
end
create_table "rights_roles", :id => false, :force => true do |t|
t.column "right_id", :integer
t.column "role_id", :integer
end
create_table "roles", :force => true do |t|
t.column "name", :string
t.column "description", :text
end
Rights...
2006 Dec 08
19
HABTM join table quirk
...for our environment were added..but are minor.)
Since I initially let Rails create the join table between two data
tables with a HABTM relationship....I assumed it would know HOW to do it
correctly. Oh well...maybe not. My tables looked like this:
Rights
ID
name
Roles
ID
rolename
Rights_Roles
ID
right_id
role_id
The ID field is basically unneeded since this table is only for the many
to many relationship. I was getting a problem when trying to add a
second record to the table. It turns out the HABTM relationship was
adding one of the foreign keys as the ID field as well as i...
2006 Apr 15
8
Migrations - adding a new table and automatically creating records
I want to create table called roles and then populate it with some new
records...This doesn''t work. Is there something I''m missing?
Craig
class AddRightsAndRolesTables < ActiveRecord::Migration
def self.up
create_table :roles do |t|
t.column "name", :string
end
Role.reset_column_information
Role.new :name => "Users Admin"
2006 Apr 27
7
Role Based Authorization recipe implementation?
i got the rails recipes book, i have now an auth system for users
without problems, now i want to made a role based acces for my app, im
following the "Role Based Authorization" recipe of the book but i cant
make it to work even when the tables created and correctly added data
manually definig the roles and rights. als i dont know how to define a
right for use all the actions in a