ruby - Rails Console Help Needed HABTM relationship -


i'm trying figure out command update roles_users model using console. using cancan devise , i'm trying set seeds.rb. wanted test first.

my users have many roles , vice versa. working fine , roles_users table has been populated.

what i'm trying figure out how update user in console.

i can see development log following happens:

insert "roles_users" ("role_id", "user_id") values (3, 1) 

how can in console??

thanks

user.find(user_id).roles << role.find(role_id)


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -