Displaying 16 results from an estimated 16 matches for "roles_us".
2006 Apr 15
6
view code regular expression
I''m lost on regular expressions to begin with...
I''m trying to fix a value to one of 4 radio buttons as there will be
value of either 1,2,3 or 4 in @roles_users...
<TD><input type="radio" id="roles"
name="case_managers[case_manager_name]"
value="Case Manager Admin"
<% if =~ @roles_users /1/ checked = "checked" %> /></TD>
<TD><input type="radio"...
2006 Apr 16
6
still learning maintaining data with join tables
Class Role
has_and_belongs_to_many :users
Class User
has_and_belongs_to_many :roles
Class RolesUsers
has_and_belongs_to_many :roles
has_and_belongs_to_many :users
According to the logs...I''m good through here
@roles_users = RolesUsers.find(:all,
:conditions => ["user_id = ?", params[:users_id]] )
the next section of controller code is a problem...
for entry in @roles_users do
entry.destroy
end
ActiveRecord::StatementInvalid in LoginController#save_rights
PGError: ERROR: rela...
2006 Jul 11
1
Problems using the authorization plugin from Bill Katz
...rails stuff)
r = Red.find(1)
u1 = User.find_by_login("ismael")
u2 = User.find_by_login("ismael2")
u1.has_role "proprio", r
u2.has_role "proprio", r
ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry ''5'' for
key 1: INSERT INTO roles_users (`updated_at`, `role_id`, `id`,
`user_id`, `created_at`) VALUES (''2006-07-11 13:58:35'', 5, 5, 20,
''2006-07-11 13:58:35'')
I know what the Duplicate key mean, but am I using the plugin
correctly or you cant have 2 users with the same permission on the
same obje...
2008 Mar 23
1
radio buttons - how to identify record using value?
I''m making a simple questionnaire app using RoR. I''ve got a model for
Questions, a model for Answers, and a third model, Qa, for matching each
question to five possible answers through foreign keys. So, each qa has
a question and five answers , a1-a5, through belongs_to and a
:foreign_key, and then a selected_answer field for specifying which
answer was selected by the user. The
2006 Aug 18
9
Rails is doing what I want - but I don''t understand how.
...to_many :users
has_and_belongs_to_many :rights
def self.names
names = Array.new()
for role in Role.find :all
names << role.name
end
return names
end
end
migration file for reference:
class CreateRoles < ActiveRecord::Migration
def self.up
create_table :roles_users, :id => false do |t|
t.column "role_id", :integer
t.column "user_id", :integer
end
create_table :roles do |t|
t.column "name", :string
end
end
def self.down
drop_table :roles_users
drop_table :roles
end
end
As you can see...
2005 Mar 10
8
Login controller additions
I have added roles and roles_users table and updated the model so that
my users can have multiple roles.
("Admin" role does always have id = 1).
I have added these methods to my application controller.
<code>
helper_method :is_admin?
helper_method :is_user?
def is_admin?
if @session[''user&...
2005 Oct 11
4
Searching an attribute in a hmabtm relationship
(Nuby to Ruby and Rails...)
I''ve implemented security using the login generator in a simple app so
that I have a user table, a roles table, and a join between them
(roles_users). All works as expected. I now need to check if a user
has a specific role, but my approach is off somehow.
Here''s what I''ve tried thusfar:
user_roles = @session[:user].roles
user_roles.find { |r| r.name == "officer"}
When this executes, I get &...
2005 Dec 14
3
why would an int column in a join table be a String class in model?
...with integer columns in the database becoming strings in
the model and I''m not sure why this is happening. perhaps someone can
explain.
given the following setup (simplified for example)
tables:
users
----------
id - int
name - varchar(60)
roles
----------
id - int
name - varchar(60)
roles_users (join table)
----------
role_id - int
user_id - int
default_flag - int
data:
user => 1, ''joe''
role => 1, ''admin''
roles_users => 1, 1, 1
models:
class User < ActiveRecord::Base
has_and_belongs_to_many :roles
end
class Role < ActiveRecord::...
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
...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 using polymorphic associations...
2006 Sep 05
0
rake craziness with Migrate as a dependency
..., ["static_permission_id",
"role_id"], {:name=>"roles_static_permissions_all_index",
:unique=>true})
-> 0.2200s
-- add_index("roles_static_permissions", ["role_id"],
{:name=>"role_id"})
-> 0.2400s
-- create_table("roles_users", {:force=>true, :id=>false})
-> 0.0800s
-- add_index("roles_users", ["user_id", "role_id"],
{:name=>"roles_users_all_index", :unique=>true})
-> 0.1810s
-- add_index("roles_users", ["role_id"], {:name=>&q...
2007 Aug 23
6
Saving ActiveRecord in PostgreSQL without id
I have a small table that is used to temporarily queue requests, as such
it does not have an id field (or any other primary key), because it
doesn''t make sense to have one.
When I created an ActiveRecord class and tried to save it, I get:
ActiveRecord::StatementInvalid: PGError: ERROR: relation
"temp_requests_id_seq" does not exist
It keeps looking for the id to auto
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
2006 Aug 11
0
SQL sort
...></td> #1st
role is main role
<td width="30%" align="center"><%= h(user.first_name) %></td>
<td width="20%" align="center"><%= h(user.last_name) %></td>
user and roles are joined by a many-to-many relationship (roles_users
table)
Its running very well... but I would like to be able to sort on the role
column...
when "role" then "role DESC" doesn''t work obviously
I got a MYSQL error
Mysql::Error: Unknown column ''role'' in ''order clause'': SELECT...
2005 Oct 13
0
Re: rubyonrails problem w/ multiple dbs and webrick
..., I wound up just using a single connection (for the site DB), and
then overriding the table names to include the DB name ("rails"), e.g.:
class User < ActiveRecord::Base
set_table_name "rails.users"
has_and_belongs_to_many :roles, :join_table => "rails.roles_users"
...
There''s also probably a DRYer way of doing this (suggestions welcome!), and it
may very well be MySQL-specific. but it works for me (YMMV).
[0] http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000738
========================================================...
2006 Jun 26
1
Rake + SQL Server + Migrations == Errors. Help?!
...abaseError: Count
OLE error code:8000FFFF in Microsoft OLE DB Provider for SQL Server
ITransaction::Commit or ITransaction::Abort was called, and object is
in a zombie state.
HRESULT error code:0x80020009
Exception occurred.: EXEC sp_helpindex roles
# Could not dump table "roles_users" because of following DBI::DatabaseError
# EOF
OLE error code:800A0E78 in ADODB.Recordset
Operation is not allowed when the object is closed.
HRESULT error code:0x80020009
Exception occurred.
# Could not dump table "sales_lot_status" because of following
DBI...
2010 Jun 05
6
How do you update HABTM relationships or create.
Hi,
I have a User model with a HABTM relation to a Role model and vice
versa. So There''s a roles_users table that references :user and :role.
I''m using formtastic, and in the user.edit.html.erb I have a line that
outputs the roles as a multi-select list box. But the box is not
showing the roles that have been assigned to the users.
Another problem is that if I select a few roles and pr...