Sunil Gowda
unread,Feb 26, 2012, 2:52:32 PM2/26/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to acl9-discuss
I am on Rails3 and has_role! invocation fails. I think I have
everything setup correctly. Do I need to create a RoleUser class?
user.has_role! :admin
Role Load (0.5ms) SELECT "roles".* FROM "roles" WHERE (name = 'admin'
and authorizable_type IS NULL and authorizable_id IS NULL) LIMIT 1
Role Exists (0.5ms) SELECT 1 FROM "roles" INNER JOIN "roles_users"
ON "roles"."id" = "roles_users"."role_id" WHERE
"roles_users"."user_id" = 1 AND "roles"."id" = 112 LIMIT 1
(0.1ms) BEGIN
(0.3ms) INSERT INTO "roles_users" ("user_id", "role_id") VALUES
(1, 112)
(0.1ms) ROLLBACK
ActiveRecord::StatementInvalid: PG::Error: ERROR: null value in
column "created_at" violates not-null constraint
: INSERT INTO "roles_users" ("user_id", "role_id") VALUES (1, 112)
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/connection_adapters/
postgresql_adapter.rb:1106:in `async_exec'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/connection_adapters/
postgresql_adapter.rb:1106:in `exec_no_cache'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/connection_adapters/
postgresql_adapter.rb:650:in `block in exec_query'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/connection_adapters/
abstract_adapter.rb:280:in `block in log'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activesupport-3.2.1/lib/active_support/notifications/instrumenter.rb:
20:in `instrument'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/connection_adapters/
abstract_adapter.rb:275:in `log'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/connection_adapters/
postgresql_adapter.rb:649:in `exec_query'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/connection_adapters/abstract/
database_statements.rb:61:in `exec_insert'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/connection_adapters/abstract/
database_statements.rb:88:in `insert'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/connection_adapters/abstract/
query_cache.rb:14:in `insert'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/
has_and_belongs_to_many_association.rb:29:in `insert_record'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/
collection_association.rb:492:in `block (2 levels) in concat_records'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/
collection_association.rb:342:in `add_to_target'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/
collection_association.rb:491:in `block in concat_records'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/
collection_association.rb:489:in `each'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/
collection_association.rb:489:in `concat_records'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/
collection_association.rb:134:in `block in concat'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/
collection_association.rb:149:in `block in transaction'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/connection_adapters/abstract/
database_statements.rb:190:in `transaction'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/transactions.rb:208:in
`transaction'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/
collection_association.rb:148:in `transaction'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/
collection_association.rb:134:in `concat'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/
activerecord-3.2.1/lib/active_record/associations/collection_proxy.rb:
117:in `<<'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/acl9-0.12.0/lib/
acl9/model_extensions/for_subject.rb:66:in `has_role!'
from (irb):28
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.1/
lib/rails/commands/console.rb:47:in `start'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.1/
lib/rails/commands/console.rb:8:in `start'
from /Users/sunilgowda/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.1/
lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'