Skip to content

Instantly share code, notes, and snippets.

@healthhiway
Created June 7, 2010 09:30
Show Gist options
  • Save healthhiway/428456 to your computer and use it in GitHub Desktop.
Save healthhiway/428456 to your computer and use it in GitHub Desktop.
#delete the users
User.all.each { |u|
u.access_context = {:user=>u.id.to_s}
u.destroy
}
#create the users
User.create(:login => 'root1',
:password => 'root',
:role => 'root',
:email => '[email protected]',
:first_name => 'root',
:last_name => 'root',
:domain => 'phr'
)
User.create(:login => 'root2',
:password => 'root',
:role => 'root',
:email => '[email protected]',
:first_name => 'root',
:last_name => 'root',
:domain => 'phr'
)
u1=User.first(:login=>"root1")
u2=User.first(:login=>"root2")
u1.access_context = {:user=>u1.id.to_s}
u1.grant_access_to! :user=>u2.id.to_s, :access=>"manage"
u1.save!
u1=User.first(:login=>"root1")
u2=User.first(:login=>"root2")
u1.access_context = {:user=>u2.id.to_s}
u2.access_context = {:user=>u2.id.to_s}
puts "u2 manages #{u2._manages.inspect}"
puts "u1's email id is #{u1.email}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment